Utf8.next

From GiderosMobile
Revision as of 23:08, 1 December 2023 by MoKaLux (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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