function love.load()
text = "Type away! -- "
end
function love.keypressed(key, unicode)
-- ignore non-printable characters (see http://www.ascii-code.com/)
if unicode > 31 and unicode < 127 then
text = text .. string.char(unicode)
print(unicode)
end
end
function love.draw()
love.graphics.printf(text, 0, 0, 800)
end
accented letters (é,è...) never print, neither the unicode in the console.
Your suggestion of removing a vital part of the code will lead to errors. There's generally a reason why code was written in a certain way, though bad code exists too.
string.char takes an integer from 0 to 255 and returns a string with the character representation of that number. This usually maps the number to the byte (depends on the locale which should default to C).
All LÖVE functions (with one exception) take UTF-8 encoded strings. UTF-8 is compatible with ASCII (a 7-bit encoding) and the limitation in the example function makes sure it stays in the printable character range. All characters above the value 127 use two or more bytes when encoded with UTF-8.
If you want to add characters outside of ASCII to a string, you'll have to encode them in UTF-8. LÖVE does not offer functions for this, but there should be a few pure Lua libraries that do it.