Difference between revisions of "Utf8.next"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
 
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
+
'''Available since:''' Gideros 2016.06<br/>
'''<translate>Available since</translate>:''' Gideros 2016.06<br/>
+
'''Class:''' [[utf8]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/utf8|utf8]]<br/>
+
 
=== <translate>Description</translate> ===
+
=== Description ===
<translate>Iterate though the UTF-8 string s. If only s is given, it can used as a iterator:
+
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
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>
+
</syntaxhighlight>
<syntaxhighlight lang="lua">
+
 
(varies) = utf8.next(s,charpos,offset)
+
If only ''charpos'' is given, returns the next byte offset of in string.
</source>
+
 
=== <translate>Parameters</translate> ===
+
If ''charpos'' and ''offset'' are given, a new charpos will be calculated, by add/subtract UTF-8 char offset to current charpos.
'''s''': (string) <translate></translate> <br/>
+
 
'''charpos''': (number) <translate></translate> '''optional'''<br/>
+
In all cases, it returns a new char position (in bytes), and code point (a number) at this position.
'''offset''': (number) <translate></translate> '''optional'''<br/>
+
 
=== <translate>Return values</translate> ===
+
=== Parameters ===
'''<translate>Returns</translate>''' (varies) <translate>next iteration</translate><br/>
+
'''s''': (string) <br/>
 +
'''charpos''': (number) '''optional'''<br/>
 +
'''offset''': (number) '''optional'''<br/>
 +
 
 +
=== Return values ===
 +
'''Returns''' (varies) next iteration<br/>
  
 
{{Utf8}}
 
{{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