Garry's Mod Wiki

utf8.codes

function utf8.codes( string string )

Description

Returns an iterator (like string.gmatch) which returns both the position and codepoint of each utf8 character in the string. It raises an error if it meets any invalid byte sequence.

Arguments

1 string string
The string that you will get the codes from.

Returns

1 function
The iterator (to be used in a for loop).

Example

Demonstrates usage of the function.

for p, c in utf8.codes("( ͡° ͜ʖ ͡°)") do print(p,c) end
Output:
1 40 2 32 3 865 5 176 7 32 8 860 10 662 12 32 13 865 15 176 17 41

Page Links


Special Pages


Wikis

?

Render Time: 35ms

DB GetPage 6
Generate Html 4
SaveChanges (1) 11
Render Body 0
Render Sidebar 12