Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
api:unicode [2015/04/11 16:35]
sangar
api:unicode [2015/06/11 22:23] (current)
gamax92 Fix this finally, someone else can go make better documentation though.
Line 9: Line 9:
 - `unicode.char(value:​ number, ...): string`  ​ - `unicode.char(value:​ number, ...): string`  ​
   UTF-8 aware version of `string.char`. The values may be in the full UTF-8 range, not just ASCII.   UTF-8 aware version of `string.char`. The values may be in the full UTF-8 range, not just ASCII.
 +- `unicode.charWidth(value:​ string, ...): number`  ​
 +  Returns the width of the first character given. For example, for `シ` it'll return `2`, where `a` would return `1`.
 +- `unicode.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`.
 - `unicode.len(value:​ string): number`  ​ - `unicode.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`.   UTF-8 aware version of `string.len`. For example, for `Ümläüt` it'll return `6`, where `string.len` would return `9`.
Line 19: Line 23:
 - `unicode.upper(value:​ string): string`  ​ - `unicode.upper(value:​ string): string`  ​
   UTF-8 aware version of `string.upper`.   UTF-8 aware version of `string.upper`.
 +- `unicode.wlen(value:​ string): number`  ​
 +  Returns the width of the entire string.
 +- `unicode.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.
  
 For example, these are used when files are opened in non-binary mode. The original string functions are used for files opened in binary mode. For example, these are used when files are opened in non-binary mode. The original string functions are used for files opened in binary mode.