How to convert a character to a dezimal ASCII code?
So for example "a" should be converted to 97.
I figured it out by myself.
You can cast a char into an int with: int('a') or ord('a').
"a" in Nim is a string, not a char. So at first you need to get the character you want the ASCII code from. In this case the first character inside the string.
So int(char("a"[0])) would give the ASCII code for the first character inside a string.
The same procedure works also in the other direction. To convert an ASCII code into a character, you do char(97) and get 'a'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With