duktape: Unicode string problem
In one of my unit tests I create a folder “Κάποιος κατάλογος” in a workdir. Then cd
into that and read the current work dir. This suprisingly gives me:
x chdir (0 of 1 succeeded) Failure: Expected ‘output/process-specs/currentPath/Κάποιος κατάλογος’ to be ‘output/process-specs/currentPath/Κάποιος κατάλογος’.
When I print both strings char by char I can see why comparison fails. The string managed in JS is stored in non-combined form (NFD?) while the file system returns a composed string (probably NFC). This is relevant for the 2 ά
letters. Removing them makes the test succeed.
Obviously I have to normalize the strings, however duktape doesn’t seem to support that. When I call normalize() I get an error. What alternatives do I have?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 42 (27 by maintainers)
I agree, but JS is stuck with a bunch of legacy baggage to avoid “breaking the web”. It sucks, but it is what it is. 😃
That said, JS as a language is slowly getting better support for Unicode proper as time goes on. Unicode character escapes,
/u
mode for regexps,String.fromCodePoint()
, etc.