perl-unicode

Re: BOM and principle of least surprise

2004-03-19 04:30:05
Erland Sommarskog <sommar(_at_)algonet(_dot_)se> writes:
  
  open (F,  '<:encoding(ucs-2le)', 'räkmacka-ucs2.txt');

And one things seems just plain wrong to me: The "\n" is written as 
0A 0D to the file, not 000A, 000D. But may there is some more manual
reading I need to do find out how to do it.

0A 0D is fine for a UTF-8 file. 

For a UCS-2 file things are not very automatic.

This scheme should work:
Turn off the low level CRLF handling, then add the widening layer,
then add a crlf converter and finally tell perl the stack can handle UTF8:

   open (F,  '>:raw:encoding(ucs-2le):crlf:utf8', 'as-ucs2.txt');


<Prev in Thread] Current Thread [Next in Thread>