On 20 June 2014 12:33, Abinoam Jr. <abinoam / gmail.com> wrote:

>
> Another source of error (at least for me) is that some UTF_16 streams
> just lacks that "BOM" comand (Byte Order Mark), so it cannot guess if
> it is little endian or big endian. So you could "hint" it with
> Encoding::UTF_16BE or Encoding::UTF_16LE.
>
>
This is the most common problem, AFAIK. If your data doesn't have a BOM
(the first bytes = 0xFFFE or 0xFEFF) then the system can't know which
UTF-16 encoding you're using.

Here's a much tinier gist than Abinoam's, which does some inter-process
communications: https://gist.github.com/phluid61/40b9d5b32c9edabaae07

Cheers
-- 
  Matthew Kerwin
  http://matthew.kerwin.net.au/