WoW:API strbyte: Difference between revisions

Updated to match the API boilerplate.
(Use Lua/Libshortcut template. Change category from "LUA Functions" to "Lua functions".)
(Updated to match the API boilerplate.)
Line 1: Line 1:
{{:Lua/Libshortcut|strbyte|string.byte}}
{{:Lua/Libshortcut|strbyte|string.byte}} __NOTOC__
string.byte(s [, i])


Return the numerical code the i-th character of the string passed.
Returns the numerical code of a character in a string.
indexByte = string.byte(s [, index])


== Arguments ==
:s [, index]
:; s : String - The string to get the numerical code from
:; index : Number - Optional argument specifying the index of the character to get the byte value of
== Returns ==
:; indexByte : Number - The byte value of the character at the specified position or nil if the index is invalid
== Example ==
  > = string.byte("ABCDE")      -- no index, so the first character
  > = string.byte("ABCDE")      -- no index, so the first character
  65
  65
Line 11: Line 23:
  > = string.byte("ABCDE",100)  -- index out of range, no value returned
  > = string.byte("ABCDE",100)  -- index out of range, no value returned


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


{{LUA}}
{{LUA}}
Anonymous user