There is a function in scripts\1_core\proto\enstring.c that claims to return the ASCII value of the first character in a string:
/** \brief Converts string's first character to ASCII code \param str String for convert to ASCII code \return \p ascii code \p int. @code int ascii = "M".ToAcsii(); Print(ascii); >> ascii = 77 @endcode */ proto int ToAscii(string str);
There is a typo in the documentation: "ToAcsii" should be "ToAscii". I corrected this typo before running the example:
void ToAsciiTest() { int ascii = "M".ToAscii(); Print(ascii); }
However, even after correcting the typo, running the example code still reports an error, "Not enough parameters in function 'ToAscii'":
Since the ToAscii method requires an argument, I tried changing the code to:
void ToAsciiTest() { int ascii = "M".ToAscii("N"); Print(ascii); }
However, the resulting output does not include the ASCII value of "M" (77) or "N" (78). Instead, it seems that the ToAscii method always returns 0:
SCRIPT : int ascii = 0
Is there a correct way to use the string.ToAscii method so that it actually returns the ASCII value of the first character of the string?