Closed Bug 1019169 Opened 7 years ago Closed 7 years ago
[NFC] Fix UTF <-> byte arrays conversions
46 bytes, text/x-github-pull-request
|Details | Review|
As was discovered in bug 1013845, we need to fix UTF <-> Uint8Array conversions in NFC. When we're handling user input, we get UCS-2 string, but fromUTF8()/toUTF8() in NfcUtils are assuming it's UTF-8. This causes them to return invalid values for some diacritic characters. Steps to reproduce: > NfcUtils.toUTF8(NfcUtils.fromUTF8("łąka")) !== "łąka" // true Also, use of .chareCodeAt() is invalid, because it can return values > 255 and those get truncated in Uint8Array.
Fix for UTF8/16 <-> Uint8Array conversions, with test cases.
Attachment #8433547 - Flags: review?(alive)
Attachment #8433547 - Flags: review?(alive) → review?(gweng)
Comment on attachment 8433547 [details] [review] Pull request Since I'm not expert in text encoding, I can only read out that you removed the old manual encoding method with new Gecko APIs. If so, the patch looks good on me.
Attachment #8433547 - Flags: review?(gweng) → review+
Reverted for frequent Gaia unit test failures. Master: https://github.com/mozilla-b2g/gaia/commit/26978ca1619e7c2a50c6b1d9347dcaebe673f552 https://tbpl.mozilla.org/php/getParsedLog.php?id=41135842&tree=B2g-Inbound
Sorry for this bug, I've got race condition where two patches landed in a short timeframe, that's why tests were passing on my machine and Travis.
Attachment #8433547 - Attachment is obsolete: true
7 years ago
You need to log in before you can comment on or make changes to this bug.