Difference between revisions of "Utf8.widthindex"
From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2016.06<br/> === Description === Return the character index at given location in string s. this is a reverse operation of utf8.width()...") |
|||
Line 4: | Line 4: | ||
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. | 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. | ||
<source lang="lua"> | <source lang="lua"> | ||
− | (number) | + | (number) = utf8.widthindex(s,location,ambi_is_double,default_width) |
</source> | </source> | ||
− | '''s | + | '''s''': (string) ''''''<br/> |
− | '''location | + | '''location''': (number) ''''''<br/> |
− | '''ambi_is_double | + | '''ambi_is_double''': (boolean) '''optional'''<br/> |
− | '''default_width | + | '''default_width''': (number) '''optional'''<br/> |
'''Returns''' (number) character index at given location<br/> | '''Returns''' (number) character index at given location<br/> |
Revision as of 10:21, 23 August 2018
Available since: Gideros 2016.06
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.
(number) = utf8.widthindex(s,location,ambi_is_double,default_width)
's: (string) '
'location: (number) '
ambi_is_double: (boolean) optional
default_width: (number) optional
Returns (number) character index at given location