char() returns utf-8 bytes of a string. even setting aside the bytes vs codepoints thing, this is different from character literals in that it ignores the current table mapping. char("X",0) being different from 'X' feels really bad to me.
dunno what we should do. i guess one relatively simple solution is making char() return the Nth unicode codepoint of the string, looked up through the table mapping. this does make it quadratic time to iterate through a string, but asar has some stupid O(n^2) places already, we can optimize it if it actually becomes a problem (probably via python-style "upgrade string to utf32 if necessary").
i was going to insert some rambling here about how this could lead to surprises if the table mapping is not injective and some string processing code tries to compare characters for equality, but this is probably rare enough to ignore and i can't think of any good solution for that case anyways.
char()returns utf-8 bytes of a string. even setting aside the bytes vs codepoints thing, this is different from character literals in that it ignores the current table mapping.char("X",0)being different from'X'feels really bad to me.dunno what we should do. i guess one relatively simple solution is making char() return the Nth unicode codepoint of the string, looked up through the table mapping. this does make it quadratic time to iterate through a string, but asar has some stupid O(n^2) places already, we can optimize it if it actually becomes a problem (probably via python-style "upgrade string to utf32 if necessary").
i was going to insert some rambling here about how this could lead to surprises if the table mapping is not injective and some string processing code tries to compare characters for equality, but this is probably rare enough to ignore and i can't think of any good solution for that case anyways.