Utf8.charpos

From GiderosMobile

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