Difference between revisions of "Utf8.next"
From GiderosMobile
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | ''' | + | '''Available since:''' Gideros 2016.06<br/> |
− | === | + | '''Class:''' [[utf8]]<br/> |
− | + | ||
+ | === Description === | ||
+ | Iterates through the UTF-8 string ''s''. | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | (varies) = utf8.next(s,charpos,offset) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | If only ''s'' is given, it can used as a iterator: | ||
+ | <syntaxhighlight lang="lua"> | ||
for pos, code in utf8.next, "utf8-string" do | for pos, code in utf8.next, "utf8-string" do | ||
-- ... | -- ... | ||
end | end | ||
− | + | </syntaxhighlight> | |
− | + | ||
− | + | If only ''charpos'' is given, returns the next byte offset of in string. | |
− | + | ||
− | === | + | If ''charpos'' and ''offset'' are given, a new charpos will be calculated, by add/subtract UTF-8 char offset to current charpos. |
− | '''s''': (string) | + | |
− | '''charpos''': (number) | + | In all cases, it returns a new char position (in bytes), and code point (a number) at this position. |
− | '''offset''': (number) | + | |
− | === | + | === Parameters === |
− | ''' | + | '''s''': (string) <br/> |
+ | '''charpos''': (number) '''optional'''<br/> | ||
+ | '''offset''': (number) '''optional'''<br/> | ||
+ | |||
+ | === Return values === | ||
+ | '''Returns''' (varies) next iteration<br/> | ||
+ | |||
+ | {{Utf8}} |
Latest revision as of 22:08, 1 December 2023
Available since: Gideros 2016.06
Class: utf8
Description
Iterates through the UTF-8 string s.
(varies) = utf8.next(s,charpos,offset)
If only s is given, it can used as a iterator:
for pos, code in utf8.next, "utf8-string" do
-- ...
end
If only charpos is given, returns the next byte offset of in string.
If charpos and offset are given, a new charpos will be calculated, by add/subtract UTF-8 char offset to current charpos.
In all cases, it returns a new char position (in bytes), and code point (a number) at this position.
Parameters
s: (string)
charpos: (number) optional
offset: (number) optional
Return values
Returns (varies) next iteration