utf8.codepoint()

Type Function
Library utf8.*
Return value Numbers
Revision Release 2022.3683
Keywords utf8, UTF-8, Unicode, string, codepoint

Overview

Returns the code points (as integers) from all characters in a string that start between two byte positions (both included).

The default for end is the number of characters in the string. This function raises an error if it finds an invalid byte sequence.

Syntax

utf8.codepoint( s [, start [, end]] )
s (required)

String. The string to examine.

start (optional)

Number. Starting position. Default is 1.

end (optional)

Number. Ending position. Default is the number of characters in the string.

Example

local utf8 = require( "plugin.utf8" )

local testStr = "♡ 你好,世界 ♡"

print( utf8.codepoint( testStr, 1, 5 ) )  --> 9825  32  20320