Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How to handle unicode txt file on Windows

by almut (Canon)
on Nov 03, 2008 at 17:13 UTC ( [id://721151]=note: print w/replies, xml ) Need Help??


in reply to How to handle unicode txt file on Windows

FFFE is the marker for UTF-16LE, not UTF-8... (so, ":encoding(UTF-16LE)" might work better)

Replies are listed 'Best First'.
Re^2: How to handle unicode txt file on Windows
by ikegami (Patriarch) on Nov 03, 2008 at 20:38 UTC
    And :encoding(UTF-16) will work even better since it absorbs the BOM.
      What would happen if it's called on a non-unicode file?

        Using :encoding(UTF-16) on a file not encoded using UTF-16 will likely die as a result of not finding \xFE\xFF or \xFF\xFE at the start of the file.

        Using :encoding(UTF-16le) on a file not encoded using UTF-16le will result in garbage and/or die.

        You must know the encoding of the file to be able to read it.

        I think File::BOM will help you. It imposes an limitation (the presence of a BOM for non-default encodings), but that doesn't sound like a problem for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://721151]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found