I'm a newb. Re: https://nim-lang.org/docs/system.html#chr%2Crange%5B%5D
This single-line code:
echo chr(97) # a
Returns the letter "a" All Unicode decimal numbers up to 127 work.
But all Unicode numbers from 128 - 255 return � (replacement character)
This also happens to be the cutoff between Basic Latin and Latin-1 Supplement. https://en.wikipedia.org/wiki/List_of_Unicode_characters#Latin-1_Supplement
I've tried the corresponding function in Python on the terminal to see, but Python produces the correct character.
What am I missing?
Thank you,
More specifically if you want to turn numbers into unicode characters you need to use the unicode module:
import unicode
for i in 120..127:
echo i, ": ", i.Rune
for i in 162..168:
echo i, ": ", i.Rune
Ah! Thank you so much. https://theasciicode.com.ar/
With ASCII, the problem still exists: any number 127 or higher produces �.
It seems that UTF-8 uses 2 bytes to store extended latin characters, and thus not (binary-) compatible with Latin-1.
echo len("\u00e6") # 2