Utf8.next: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
Line 2: Line 2:
'''Available since:''' Gideros 2016.06<br/>
'''Available since:''' Gideros 2016.06<br/>
=== Description ===
=== Description ===
Iterate though the UTF-8 string s. If only s is given, it can used as a iterator:
<translate>Iterate though the UTF-8 string s. If only s is given, it can used as a iterator:
for pos, code in utf8.next, "utf8-string" do
for pos, code in utf8.next, "utf8-string" do
-- ...
-- ...
end
end
if only charpos is given, return the next byte offset of in string. 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 (in bytes), and code point (a number) at this position.
if only charpos is given, return the next byte offset of in string. 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 (in bytes), and code point (a number) at this position.</translate>
<source lang="lua">
<source lang="lua">
(varies) = utf8.next(s,charpos,offset)
(varies) = utf8.next(s,charpos,offset)
</source>
</source>
=== Parameters ===
=== Parameters ===
'''s''': (string) <br/>
'''s''': (string) <translate></translate> <br/>
'''charpos''': (number) '''optional'''<br/>
'''charpos''': (number) <translate></translate> '''optional'''<br/>
'''offset''': (number) '''optional'''<br/>
'''offset''': (number) <translate></translate> '''optional'''<br/>
=== Return values ===
=== Return values ===
'''Returns''' (varies) next iteration<br/>
'''Returns''' (varies) <translate>next iteration</translate><br/>

Revision as of 12:32, 23 August 2018

Available since: Gideros 2016.06

Description

Iterate though the UTF-8 string s. 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, return the next byte offset of in string. 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 (in bytes), and code point (a number) at this position.

(varies) = utf8.next(s,charpos,offset)

Parameters

s: (string)
charpos: (number) optional
offset: (number) optional

Return values

Returns (varies) next iteration