NAME
unicode - API for working with UTF-8 strings
DESCRIPTION
The unicode library provided by OpenComputers provides all functions of the string library, except UTF-8 aware.
METHODS
The following functions are provided to allow basic UTF-8 handling:
char(value:number, ...): string
UTF-8 aware version of string.char. The values may be in the full UTF-8 range, not just ASCII.
charWidth(value:string, ...): number
Returns the width of the first character given. For example, for シ it'll return 2, where a would return 1.
isWide(value:string, ...): boolean
Returns if the width of the first character given is greater than 1. For example, for シ it'll return true, where a would return false.
len(value:string): number
UTF-8 aware version of string.len. For example, for Ümläüt it'll return 6, where string.len would return 9.
lower(value:string): string
UTF-8 aware version of string.lower.
reverse(value:string): string
UTF-8 aware version of string.reverse. For example, for Ümläüt it'll return tüälmÜ, where string.reverse would return tälm.
sub(value:string, i:number[, j:number]): string
UTF-8 aware version of string.sub.
upper(value:string): string
UTF-8 aware version of string.upper.
wlen(value:string): number
Returns the width of the entire string.
wtrunc(value:string, count: number): string
Truncates the given string up to but not including count width. If there are not enough characters to match the wanted width, the function errors.
NOTES
In Lua 5.3, some UTF-8 facilities may be used through the global utf8 table.
SEE ALSO
component(2), computer(2)