0 Members and 3 Guests are viewing this topic.
ch="²"string.len(ch) --returns 2b1=ch:byte(1) --returns 194b2=ch:byte(2) -- returns 178chr = string.byte(194, 178) --returns ²
Well, string.byte looks at the string as if it would be ascii, but in fact the nspire uses utf-8. UTF-8 uses multiple bytes, unlike ascii. And since string.byte is for ascii, it takes only the first byte, 194.To make a story short, you need string.char(194, 178) for ². 194 is the first byte, 178 the second. Now, to find the bytes of a utf-8 char first use string.len, to see how many bytes there are. Then use string.byte to fetch the chars:Code: (Lua) [Select]ch="²"string.len(ch) --returns 2b1=ch:byte(1) --returns 194b2=ch:byte(2) -- returns 178chr = string.byte(194, 178) --returns ²