what does "appending keystrokes" mean?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
BozoDel
Party member
Posts: 164
Joined: Fri Nov 01, 2013 10:28 pm

what does "appending keystrokes" mean?

Post by BozoDel »

I'm not sure I get this:
In version 0.8.0 and older, love.graphics.print stops at the first '\0' (null) character. This can bite you if you are appending keystrokes to form your string, as some of those are multi-byte unicode characters which will likely contain null bytes.
It's in [wiki]love.graphics.print[/wiki]. In order to translate "appending keystrokes" most appropriately, I need to know how it works. Does it have to do with [wiki]love.textinput[/wiki]?

I'm also curious about the bug itself, was it a problem with Lua handling unicode, or with the way keystrokes were stored?
User avatar
DaedalusYoung
Party member
Posts: 413
Joined: Sun Jul 14, 2013 8:04 pm

Re: what does "appending keystrokes" mean?

Post by DaedalusYoung »

Appending keystrokes means you are changing a string, depending on user input. If a user enters a letter, you then append this letter to the string.

It doesn't have anything to do with love.textinput, because that didn't exist in 0.8.0 yet, but even if it did, it wouldn't be, since this was a print bug, not a textinput bug.

I don't know the details about the bug though.
User avatar
BozoDel
Party member
Posts: 164
Joined: Fri Nov 01, 2013 10:28 pm

Re: what does "appending keystrokes" mean?

Post by BozoDel »

Hm, but I think the user input has to come through love.textinput, otherwise there's no unicode support. I think that's it.

Any translation I can find for keystroke sounds weird, but in that case, keystroke is synonym with user input, so I can translate it more freely.
User avatar
DaedalusYoung
Party member
Posts: 413
Joined: Sun Jul 14, 2013 8:04 pm

Re: what does "appending keystrokes" mean?

Post by DaedalusYoung »

In previous versions, love.keypressed's second argument was the unicode number of the key pressed, so there was unicode support in 0.8.0. I guess some keyboards, like Cyrillic, can send a multi-byte character from a single key press.
User avatar
markgo
Party member
Posts: 190
Joined: Sat Jan 05, 2013 12:21 am
Location: USA

Re: what does "appending keystrokes" mean?

Post by markgo »

In previous versions of Love (0.8 and older in this case), many Love text functions did not properly support UTF-8 encoded strings. The old love.keypressed receives a unicode number as its second argument. That job is now delegated to love.textinput (receives a string instead). The wiki is just warning you that if you built strings like:

Code: Select all

function love.keypressed(k,u)
  text = text .. UTF8numberToString(u)
end
The text will not be printed correctly because the text can contain null bytes from multi byte UTF-8 characters.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 10 guests