Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: A definitive way to handle encoding/decoding problems?

by halfcountplus (Hermit)
on Apr 11, 2012 at 15:08 UTC ( [id://964561]=note: print w/replies, xml ) Need Help??


in reply to A definitive way to handle encoding/decoding problems?

a) The encoding of the script is not relevant to the encoding of the data manipulated by the process as long as you indicate to perl what the script encoding is if you use non-ascii literals in it. See: encoding

b) Don't worry about (or rely on an assumption about) what internal coding perl uses. http://http://perldoc.perl.org/perlunifaq.html#I-lost-track%3B-what-encoding-is-the-internal-format-really%3F

c) If you know what the encoding of the data you are reading is, use decode() on it, or binmode(:encoding(xxx)) on the filehandle. This will convert it into the internal encoding so you can do what have you, such as encode() it into some different encoding.

binmode Encode

d) If you don't know what the encoding of read data is, that's problematic. There isn't a definitive way to sort them out.

  • Comment on Re: A definitive way to handle encoding/decoding problems?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-19 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found