string.byte

Converts a character into its ASCII (decimal) equivalent

Prototype

code = string.byte (s, n)

Description

Returns the ASCII code for the nth character of the string s. The inverse operation is carried out by string.char.

Default for n is 1.

print (string.byte ("ABC")) --> 65 (A is 65 in ASCII)
print (string.byte ("ABC", 2)) --> 66 (B is 66)

Lua functions

Topics