Difference between revisions of "Utf8.charpos"
From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight") |
|||
Line 5: | Line 5: | ||
=== <translate>Description</translate> === | === <translate>Description</translate> === | ||
<translate>convert UTF-8 position to byte offset. if only offset is given, return byte offset of this UTF-8 char index. if charpos and offset is given, a new charpos will calculate, by add/subtract UTF-8 char offset to current charpos. in all case, it return a new char position, and code point (a number) at this position.</translate> | <translate>convert UTF-8 position to byte offset. if only offset is given, return byte offset of this UTF-8 char index. if charpos and offset is given, a new charpos will calculate, by add/subtract UTF-8 char offset to current charpos. in all case, it return a new char position, and code point (a number) at this position.</translate> | ||
− | < | + | <syntaxhighlight lang="lua"> |
(number) = utf8.charpos(s,charpos,offset) | (number) = utf8.charpos(s,charpos,offset) | ||
</source> | </source> |
Revision as of 14:32, 13 July 2023
Available since: Gideros 2016.06
Class: utf8
Description
convert UTF-8 position to byte offset. if only offset is given, return byte offset of this UTF-8 char index. if charpos and offset is given, a new charpos will calculate, by add/subtract UTF-8 char offset to current charpos. in all case, it return a new char position, and code point (a number) at this position. <syntaxhighlight lang="lua"> (number) = utf8.charpos(s,charpos,offset) </source>
Parameters
s: (string)
charpos: (number) optional
offset: (number) optional
Return values
Returns (number) return byte offset of this UTF-8 char index