Just to add: There are JS APIs for this, namely TextEncoder[3] and TextDecoder[4], but browser support is incomplete. I would probably use these APIs for browsers which support them, and use the “borrowed” code as a fallback.
[3]https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder#Browser_compatibility [4]https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder#Browser_compatibility On Jul 1, 2016, at 2:39 PM, Harbs <harbs.li...@gmail.com> wrote: > We have a need to read and write UTF8 strings to “ByteArrays” in FlexJS. > FlexJS already has a BinaryData class which can serve as a stand-in for > ByteArray, but it’s missing reading and writing UTF8. I’d like to add these > methods. > > UTF8 gets a bit complicated when dealing with 2,3 and 4 byte characters. > There’s a JS library which solves this problem already on GotHub[1]. The code > was placed into public domain[2]. > > Is there any problem just adopting the part of the code relevant to UTF8? Do > we need to add a notice? > > Harbs > > [1]https://github.com/inexorabletash/text-encoding/blob/master/lib/encoding.js > [2]https://github.com/inexorabletash/text-encoding/blob/master/LICENSE.md