Closed Bug 1013845 Opened 10 years ago Closed 10 years ago

[NFC][Contacts] The Chinese words receiver receive are garbled when share contact via NFC

Categories

(Firefox OS Graveyard :: NFC, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(blocking-b2g:2.0+, b2g-v1.4 unaffected, b2g-v2.0 verified, b2g-v2.1 verified)

VERIFIED FIXED
2.0 S4 (20june)
blocking-b2g 2.0+
Tracking Status
b2g-v1.4 --- unaffected
b2g-v2.0 --- verified
b2g-v2.1 --- verified

People

(Reporter: ashiue, Assigned: kamituel)

References

Details

Attachments

(4 files)

Attached image S__1007618.jpg
Gaia c462d9183d294a2d8ecc472f593ea8cfa15bc9de Gecko https://hg.mozilla.org/mozilla-central/rev/9d8d16695f6a BuildID 20140520160203 Version 32.0a1 STR: 1. launch "settings" app for 2 phones 2. turn on "NFC" for 2 phones 3. device A create a new contact with some Chinese 4. tap two phones to share the new contact created at step 3 5. check the contact device B received Expected result: contact information should correct Actual result: Chinese is garbled
When I worked on bug 1003723 I noticed that NfcUtils.fromUTF8() and NfcUtils.toUTF8() aren't behaving correctly for non-ASCII characters. Simple test: > NfcUtils.toUTF8(NfcUtils.fromUTF8("łąka")) !== "łąka" // true There are couple of issues with current implementation: 1. When user enters input, it's not UTF-8 encoded. To achieve it, we should do something like: unescape(encodeURIComponent("łąka")) 2. This way, String.charCodeAt() will always return code < 256 which will be correctly stored in Uint8array. As of current implementation, char code for "ą" (for instance) returns 261, which is truncated when storing as 8 bit number. 3. NfcUtils.toUTF8() does not support characters consiting of more than 1 byte. It will treat them as separate characters. 4. contacts/../nfc.js does not use NfcUtils.fromUTF8(), but rather it's own implementation (also incorrect). This isn't really related to this bug, but should also be fixed in order for VCard sharing to be correct both ways. ps. in case you're wondering, "łąka" means "meadow" ;)
Assignee: nobody → kamituel
Hi folks, Changing the component to the NFC instead of contacts, since it's a general NFC problem. Thanks!
Component: Gaia::Contacts → NFC
I will fix points 1-3 in bug 1019169. Then fix this.
Depends on: 1019169
blocking-b2g: --- → 2.0?
Attached file Pull request
Fixes encoding issue by using NfcUtils.fromUTF8() instead of custom createBuffer() (which was buggy).
Attachment #8437024 - Flags: review?(francisco)
Comment on attachment 8437024 [details] [review] Pull request Forwarding review to Michal since he knows NFC better than everyone else.
Attachment #8437024 - Flags: review?(francisco) → review?(mbudzynski)
Comment on attachment 8437024 [details] [review] Pull request Tests are passing, bug is not occurring anymore (attachment), just one small nit commented on GH. Thanks Kamil, great job, working perfectly, r+ by me. Pls don't land before getting green Travis.
Attachment #8437024 - Flags: review?(mbudzynski) → review+
Thanks!
Keywords: checkin-needed
blocking-b2g: 2.0? → 2.0+
Verified on Gaia a3a5322692578e0a577fb7fa08e32144b2b05ba3 Gecko https://hg.mozilla.org/releases/mozilla-aurora/rev/0293597de41f BuildID 20140612160201 Version 32.0a2
Status: RESOLVED → VERIFIED
This issue has been verified successfully on Flame2.1. Reproducing rate: 0/5 See attachment: Verify_Flame_ContactNFC.mp4 Flame2.1 build version: Gaia-Rev ccb49abe412c978a4045f0c75abff534372716c4 Gecko-Rev https://hg.mozilla.org/releases/mozilla-b2g34_v2_1/rev/18fb67530b22 Build-ID 20141130001203 Version 34.0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: