Garry's Mod Wiki

string.byte

  vararg string.byte( string string, number startPos = 1, number endPos = startPos )

Description

Returns the given string's characters in their numeric ASCII representation.

This function will throw an error if the slice length is greater than 8000 characters.

Arguments

1 string string
The string to get the chars from.
2 number startPos = 1
The first character of the string to get the byte of.
3 number endPos = startPos
The last character of the string to get the byte of.

Returns

1 vararg
Numerical bytes

Example

Prints the first 4 numerical bytes from the string "Hello, World!"

print(string.byte("Hello, World!", 1, 4))
Output: 72 101 108 108