Re: [web-nfc] What's the value of `toJSON()`? (#366)

Text is a problem as it actually encodes language and encoding (UTF-8 or -16). Decoding this manually is actually quite hard

```js
const header = data.getUint8(0, false);
const langCodeLength = header >> 2;
const utf8Encoded = header & 0x1;
const lang = new TextDecoder.decode(data.buffer.slice(1,langCodeLength));
const text = (utf8Encoded) ? new TextDecoder.decode(data.buffer.slice(langCodeLength + 1, data.buffer.length) : null;
```

-- 
GitHub Notification of comment by kenchris
Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/366#issuecomment-542139889 using your GitHub account

Received on Tuesday, 15 October 2019 10:08:27 UTC