Difference between revisions of "Utf8.widthindex"
From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight") |
|||
Line 5: | Line 5: | ||
=== <translate>Description</translate> === | === <translate>Description</translate> === | ||
<translate>Return the character index at given location in string s. this is a reverse operation of utf8.width(). this function return a index of location, and a offset in in UTF-8 encoding. e.g. if cursor is at the second column (middle) of the wide char, offset will be 2. the width of character at idx is returned, also.</translate> | <translate>Return the character index at given location in string s. this is a reverse operation of utf8.width(). this function return a index of location, and a offset in in UTF-8 encoding. e.g. if cursor is at the second column (middle) of the wide char, offset will be 2. the width of character at idx is returned, also.</translate> | ||
− | < | + | <syntaxhighlight lang="lua"> |
(number) = utf8.widthindex(s,location,ambi_is_double,default_width) | (number) = utf8.widthindex(s,location,ambi_is_double,default_width) | ||
</source> | </source> |
Revision as of 14:32, 13 July 2023
Available since: Gideros 2016.06
Class: utf8
Description
Return the character index at given location in string s. this is a reverse operation of utf8.width(). this function return a index of location, and a offset in in UTF-8 encoding. e.g. if cursor is at the second column (middle) of the wide char, offset will be 2. the width of character at idx is returned, also. <syntaxhighlight lang="lua"> (number) = utf8.widthindex(s,location,ambi_is_double,default_width) </source>
Parameters
s: (string)
location: (number)
ambi_is_double: (boolean) optional
default_width: (number) optional
Return values
Returns (number) character index at given location