Difference between revisions of "Utf8.charpos"
From GiderosMobile
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | ''' | + | '''Available since:''' Gideros 2016.06<br/> |
− | ''' | + | '''Class:''' [[utf8]]<br/> |
− | === | + | |
− | + | === Description === | |
− | < | + | Converts UTF-8 position to byte offset. |
+ | <syntaxhighlight lang="lua"> | ||
(number) = utf8.charpos(s,charpos,offset) | (number) = utf8.charpos(s,charpos,offset) | ||
− | </ | + | </syntaxhighlight> |
− | === | + | |
− | '''s''': (string) | + | If only offset is given, returns 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 cases, it returns a new char position, and code point (a number) at this position. |
− | '''charpos''': (number) | + | |
− | '''offset''': (number) | + | === Parameters === |
− | === | + | '''s''': (string) <br/> |
− | ''' | + | '''charpos''': (number) '''optional'''<br/> |
+ | '''offset''': (number) '''optional'''<br/> | ||
+ | |||
+ | === Return values === | ||
+ | '''Returns''' (number) byte offset of this UTF-8 char index<br/> | ||
+ | |||
+ | {{Utf8}} |
Latest revision as of 21:32, 1 December 2023
Available since: Gideros 2016.06
Class: utf8
Description
Converts UTF-8 position to byte offset.
(number) = utf8.charpos(s,charpos,offset)
If only offset is given, returns 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 cases, it returns a new char position, and code point (a number) at this position.
Parameters
s: (string)
charpos: (number) optional
offset: (number) optional
Return values
Returns (number) byte offset of this UTF-8 char index