Closed leozzyzheng closed 7 years ago
Good night (or morning over there), as you seem to have noticed, utf-8 will have at most 4 bytes per character, so changing it to * 4
will be enough, thanks for the report!
Fixed by this commit!
Hmm, things don't seem to be so simple, as the test fails when changing the * 2
to * 4
(the tests fail with alternate languages to begin with), so I'll be reopening this issue for now.
It seems I got ahead of myself and reopened this issue based on first pass errors, which seem to be expected (though I didn't remember that, it's been a while since I've messed with xnb-node internals), so I'm closing this issue again, sorry for the trouble.
No worries glad to see it helps :)
In writer.js:
A Chinese character would has 3 or 4 bytes length, so 2 will cause the string truncated. I change it to 4 and seems works well, but there may be more than 4 bytes length characters in some languages.