Operations on ASCII values

Version:

5.0

Added on:

12 Sep 2014 20:42

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(const string &in s) { //Returns the ASCII value of the first character of a string.
  return s.isEmpty() ? 0 : s[0];
}
string chr(uint8 x) { //Returns a one-character string corresponding to an ASCII value.
  string s('0');
  s[0] = x;
  return s;
}