WoW Lua

Returns the numerical code of a character in a string.

indexByte = string.byte(s [, index[, endIndex]])
indexByte = strbyte(s [, index[, endIndex]])

Arguments Edit

s [, index[, endIndex]]
String - The string to get the numerical code from
Number - Optional argument specifying the index of the character to get the byte value of
Number - Optional argument specifying the index of the last character to return the value of

Returns Edit

Number - The byte value of the character at the specified position or nil if the index is invalid

Example Edit

> = string.byte("ABCDE")      -- no index, so the first character
> = string.byte("ABCDE",1)    -- indexes start at 1
> = string.byte("ABCDE",0)    -- we're not using C
> = string.byte("ABCDE",100)  -- index out of range, no value returned
> = string.byte("ABCDE", 1, 3)
65           66           67

Details Edit

The first valid index is 1.
The last valid index is the length of the string.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.