utf8.widthindex
Client-side
Server-side
Shared
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
Returns the location, offset and width of the character at the given location in the UTF-8 string.
Syntax
int, int, int utf8.widthindex utf8.widthindex ( string input, int location, [ bool ambi_is_double = false, int default_width = 0 ] )Required Arguments
- input: A string character sequence
- location: MISSING_PARAM_DESC
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- ambi_is_double (default: false): A boolean, if set to true , ambiguous character's width is 2 (see example).
- default_width (default: 0): An integer, if given, is used as width for unprintable characters.
Returns
- int: value1
- int: value2
- int utf8.widthindex: value3
Returns the given location, the offset in UTF-8 encoding (if cursor is in the middle of the wide char - offset will be 2) and the width of the character, otherwise only the location as integer will be returned.
Code Examples
shared
This example
local input = "днём"local raw_width = utf8.width( input, true )
for location = 1, raw_width do print( utf8.widthindex( input, location, true ) )end