This is an edit of Kyle Smith's utf8 library with functions for converting UTF8 strings to unicodes and vice-versa. It's useful for converting the unicode passed to keypressed and keyreleased. Enjoy!
require 'utf8'
for unicode = 1,0xD7FF do
assert(string.utf8unicode( string.utf8char(unicode) ) == unicode,unicode)
end
for unicode = 0xE000,0x10FFFF do
assert(string.utf8unicode( string.utf8char(unicode) ) == unicode,unicode)
end