Firth
Firth copied to clipboard
Strings
They're in the spec as the literal, but lack any functions to manipulate them, and they're not actually implemented in the interpreter.
A rather important note: strings should be made up of true Unicode characters (codepoints), not UTF-16 code units. That means a JS string of length four containing a surrogate pair would be a Firth string of length three, ideally.
Another thing: it should have Unicode escape sequences with the \u{xxxx...}
syntax I proposed for PHP: http://wiki.php.net/rfc/unicode_escape
Some sort of string interpolation would be great. I'm tempted to just have printf
and be done with it. Perhaps sprintf
renamed to format
.
OK, the basics of this are done now: https://github.com/TazeTSchnitzel/Firth/commit/0a249c27593a446ea268854c00ff0e5434a2d681
All that's needed are Unicode escapes and some manipulation functions. Also, it should probably error if given invalid UTF-16 input (mismatched surrogate pairs) in source, even if that's unlikely to happen.