Difference between revisions of "Utf8.charpos"
From GiderosMobile
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | '''Available since:''' Gideros 2016.06<br/> | + | '''<translate>Available since</translate>:''' Gideros 2016.06<br/> |
− | === Description === | + | === <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> | ||
<source lang="lua"> | <source lang="lua"> | ||
(number) = utf8.charpos(s,charpos,offset) | (number) = utf8.charpos(s,charpos,offset) | ||
</source> | </source> | ||
− | === Parameters === | + | === <translate>Parameters</translate> === |
'''s''': (string) <translate></translate> <br/> | '''s''': (string) <translate></translate> <br/> | ||
'''charpos''': (number) <translate></translate> '''optional'''<br/> | '''charpos''': (number) <translate></translate> '''optional'''<br/> | ||
'''offset''': (number) <translate></translate> '''optional'''<br/> | '''offset''': (number) <translate></translate> '''optional'''<br/> | ||
− | === Return values === | + | === <translate>Return values</translate> === |
− | '''Returns''' (number) <translate>return byte offset of this UTF-8 char index</translate><br/> | + | '''<translate>Returns</translate>''' (number) <translate>return byte offset of this UTF-8 char index</translate><br/> |
Revision as of 07:29, 24 August 2018
Available since: Gideros 2016.06
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.
(number) = utf8.charpos(s,charpos,offset)
Parameters
s: (string)
charpos: (number) optional
offset: (number) optional
Return values
Returns (number) return byte offset of this UTF-8 char index