Utf8.charpos: Difference between revisions

From GiderosMobile
Created page with "__NOTOC__ '''Available since:''' Gideros 2016.06<br/> === Description === convert UTF-8 position to byte offset. if only offset is given, return byte offset of this UTF-8 char..."
 
No edit summary
Line 4: Line 4:
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.
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.
<source lang="lua">
<source lang="lua">
(number), = utf8.charpos(scharposoffset,)
(number) = utf8.charpos(s,charpos,offset)
</source>
</source>
'''s:''' (string)  ''''''<br/>
'''s''': (string)  ''''''<br/>
'''charpos:''' (number)  '''optional'''<br/>
'''charpos''': (number)  '''optional'''<br/>
'''offset:''' (number)  '''optional'''<br/>
'''offset''': (number)  '''optional'''<br/>
'''Returns''' (number) return byte offset of this UTF-8 char index<br/>
'''Returns''' (number) return byte offset of this UTF-8 char index<br/>

Revision as of 09:17, 23 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)

's: (string) '
charpos: (number) optional
offset: (number) optional
Returns (number) return byte offset of this UTF-8 char index