You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UCS-2 Strings test (nan/test/js/strings.js) fails on big-endian systems #481
Running the strings.js test on a big-endian system will cause a failure in the UCS-2 test case. This is caused by the fact that the encoding function is passed the string "h\0e\0l\0l\0o\0" (see nan/test/cpp/strings.cpp, line 29), with null characters following the ASCII characters.
Little endian systems will process the characters properly (e.g. "h\0" -> 0068 -> h), however big endian systems will require that the null characters be placed in front of the letters (the 0068 example will be read as "6800", which does not map to "h" in UCS-2).
Suggested fix: Use macros to check endianness of compiling machine, and flip the bytes if necessary.
Ah, good idea, but it will be a blind fix, as we (obviously) have no big-endian systems to test on (because big-endian is unnatural...). I'll gladly merge a PR that keeps our test suite passing and take your word that it works on your end.
Upon further investigation, I have determined that this bug arises as a result of a change in the encode function in Node.js between versions v0.12 and v4.x. The encode function for UCS-2 in v0.12 reverses bytes if the system is big-endian, but in v4.x this check and reverse has been added to the string write function and removed from encode. Running nan test on v0.12 on a big-endian system results in no issues.
As a result, this bug is an issue with node, and so isn't a nan issue.
Activity
kkoopa commentedon Oct 5, 2015
Ah, good idea, but it will be a blind fix, as we (obviously) have no big-endian systems to test on (because big-endian is unnatural...). I'll gladly merge a PR that keeps our test suite passing and take your word that it works on your end.
exinfinitum commentedon Oct 6, 2015
Upon further investigation, I have determined that this bug arises as a result of a change in the encode function in Node.js between versions v0.12 and v4.x. The encode function for UCS-2 in v0.12 reverses bytes if the system is big-endian, but in v4.x this check and reverse has been added to the string write function and removed from encode. Running nan test on v0.12 on a big-endian system results in no issues.
As a result, this bug is an issue with node, and so isn't a nan issue.
Closed