Choice of BOM for UTF-16 encoding

2014-02-09 Thread Geoffrey Leach
I'm the maintainer of Audio::Taglib. 

Summary of my perl5 (revision 5 version 16 subversion 3) configuration:
osname=linux, osvers=3.10.9-200.fc19.x86_64, 
archname=x86_64-linux-thread-multi
   
$utf16 = encode("UTF-16", "\x{6211}\x{7684}") prepends a big-endian BOM. As 
best I can tell this results from U8 endian = *((U8 *)SvPV_nolen(attr("endian", 
6))); in Unicode/Unicode.xs returning null in Unicode/Unicode.xs

I presume this is what's intended. Is there a way to force (from my module) the 
choice to be LE? It turns out that the library I'm supporting (taglib) works in 
LE.

Testcase attached.

Thanks.

encode-test.pl
Description: Perl program


Re: Choice of BOM for UTF-16 encoding

2014-02-09 Thread Aristotle Pagaltzis
* Geoffrey Leach  [2014-02-10 07:35]:
> Is there a way to force (from my module) the choice to be LE? It turns
> out that the library I'm supporting (taglib) works in LE.

Does it need a BOM prepended?

If not, just do the obvious and `encode('UTF-16LE', $str)`.

C.f. `perldoc Encode::Unicode`.

Regards,
-- 
Aristotle Pagaltzis //