- From: Joshua Bell <notifications@github.com>
- Date: Tue, 19 Apr 2016 09:12:42 -0700
- To: whatwg/encoding <encoding@noreply.github.com>
Received on Tuesday, 19 April 2016 16:13:23 UTC
Assuming the JS strings are UTF-16 (which the API does), then to encode to UTF-16 is just: ```js function encode_utf16(s, littleEndian) { var a = new Uint8Array(s.length * 2), view = new DataView(a.buffer); s.split('').forEach(function(c, i) { view.setUint16(i * 2, c.charCodeAt(0), littleEndian); }); return a; } ``` --- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/encoding/issues/18#issuecomment-212000029
Received on Tuesday, 19 April 2016 16:13:23 UTC