Why Read In UTF-16LE File Won't Convert "\r\n" Into "\n" In Windows

Posted by Dbger on Stack Overflow See other posts from Stack Overflow or by Dbger
Published on 2010-04-13T03:27:39Z Indexed on 2010/04/13 3:32 UTC
Read the original article Hit count: 362

Filed under:
|
|

I am using Perl to read UTF-16LE files in Windows 7.

  1. If I read in an ascii file with following code:
    open CUR_FILE, "<", $asciiFile;

    Then each "\r\n" in file will be converted into a "\n" in memory;

  2. if I read in an UTF-16LE(windows 1200) file with following code:
    open CUR_FILE, "<:encoding(UTF-16LE)", $utf16leFile;

    Then "\r\n" will keep unchanged.

This inconsistency cause problems when I trying to regexp lines with line breaks.

My questions is:
Is this how unicode works in Perl & Windows? Or Am I using the wrong code?

Thanks so much!

© Stack Overflow or respective owner

Related posts about perl

Related posts about unicode