utf8.byte | Multi Theft Auto: Wiki Skip to content

utf8.byte

Client-side
Server-side
Shared

Returns the codepoints for the i-th through j-th character of the string passed.

Syntax

int,​ ... utf8.byte ( string input, [ int i = 1, int j = 1 ] )
Required Arguments
  • input: A string character sequence.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • i (default: 1): An integer representing the beginning position.
  • j (default: 1): An integer representing the ending position.

Returns

  • int: value1
  • ...: values

Returns a sequence of integer values from the original string if successful, nil otherwise.

Code Examples

shared

This example will print every codepoint in the input string to the console.

Output: Codepoint @ 1 = 1053 Codepoint @ 2 = 1080 Codepoint @ 3 = 1094 Codepoint @ 4 = 1094 Codepoint @ 5 = 1072 Codepoint @ 6 = 33

local input = "Ницца!"
local codepoints = {utf8.byte(input, 1, utf8.len(input))}
for index, codepoint in ipairs(codepoints) do
outputConsole("Codepoint @ " .. index .. " = " .. codepoint)
end