lua.wetgenes.txt.utf
(C) 2020 Kriss Blank under the https://opensource.org/licenses/MIT
local wutf = require("wetgenes.txt.utf")
helper functions to help manage a string as a stream of utf8 tokens.
lua.wetgenes.txt.utf.char
string = wutf.char(number)
convert a single unicode value to a utf8 string of 1-4 bytes
lua.wetgenes.txt.utf.charpattern
string:gmatch(wutf.charpattern)
lua pattern to match each utf8 character in a string
lua.wetgenes.txt.utf.chars
string = wutf.chars(number,number,...)
string = wutf.chars({number,number,...})
convert one or more unicode values into a utf8 string
lua.wetgenes.txt.utf.length
unicode = wutf.ncode(string,index)
get the utf8 value at the given code index.
Note that this is slower than wutf.code as we must search the string to find the byte index of the code.
lua.wetgenes.txt.utf.map_latin0_to_unicode
unicode = wutf.map_latin0_to_unicode[latin0] or latin0
lua.wetgenes.txt.utf.map_unicode_to_latin0
latin0 = wutf.map_unicode_to_latin0[unicode] or unicode
I prefer the coverage of latin0 (ISO/IEC 8859-15) for font layout as it is just a few small differences for western european languages to get most needed glyphs into the first 256 codes.
lua.wetgenes.txt.utf.size
size = wutf.size(string,index)
get the size in bytes of the utf8 value at the given byte index.
size = wutf.size(string)
get the size in bytes of the utf8 value at the start of this string
The return value will be 1-4 as 4 is the biggest utf8 code size.
lua.wetgenes.txt.utf.string
unicode = wutf.code(string,index)
get the utf8 value at the given byte index.
unicode = wutf.code(string)
get the utf8 value at the start of this string