Operations on ASCII values

Version:

1.0

Added on:

08 May 2013 07:44

Tags:

Description:
Although extremely simple, AS documentation never mentions how to perform these operations, so this snippet is to spare your time searching. Function explanations in comments.
uint8 ord(string &in str){ //Returns the ASCII value of the first character of a string.
  if(str.isEmpty()) {return 0;}
  return str[0];
}
string chr(uint8 value){ //Returns a one-character string corresponding to an ASCII value.
  string str="\0";
  str[0]=value;
  return str;
}