Re: [encoding] Benefits of "Legacy" Encodings – Byte Counter (#4)

@zomp 

> Do you mean st like `myTextarea.value.length`, please?

Exactly.

> If I understand it correctly this does not work – JavaScript converts the string to UTF-16, so the `.length` represents only the number of UTF-16 code units.

Yes, but the Unicode symbols that can be represented in any of those legacy single-byte encodings are all within the Basic Multilingual Plane, and would thus each have a length of `1`.

> The measurement could be done on a byte stream, but I do not know how to obtain it – it cannot be done via `(new TextEncoder('big5')).encode(myTextarea.value)` because of the UTF exclusivity.

It could be done using the libraries + code snippet I mentioned.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/encoding/issues/4#issuecomment-103579818

Received on Tuesday, 19 May 2015 16:29:15 UTC