Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Special character not being captured

by Lady_Aleena (Priest)
on Jun 17, 2019 at 19:57 UTC ( [id://11101491]=note: print w/replies, xml ) Need Help??


in reply to Re: Special character not being captured
in thread Special character not being captured

Please, would you give me your opinion why I did not need to specify encoding while the original data file was encoded as Windows-1252?

No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
Lady Aleena
  • Comment on Re^2: Special character not being captured

Replies are listed 'Best First'.
Re^3: Special character not being captured
by choroba (Cardinal) on Jun 17, 2019 at 20:09 UTC
    Because Windows-1252 encodes Æ the same way as your terminal (or browser) was configured to (e.g. Latin-1 or Windows-1252).

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^3: Special character not being captured
by ikegami (Patriarch) on Jun 24, 2019 at 22:26 UTC

    First of all, ignore any explanation that mentions latin-1. Perl doesn't know anything about latin-1.


    The lack of decoding of inputs plus the lack of encoding of outputs means the bytes were copied through. So if your input was encoded using cp1252, and if this is output to a terminal (or browser) expecting cp1252, it works.[1]

    The problem with this approach is that lots of tools expect decoded text (strings of Unicode Code Points), not encoded text (string of cp1252 bytes).

    For example,

    • /\w/ will fail to work properly.
    • uc will fail to work properly.
    • length might not do what you want (for some encodings).
    • substr might not do what you want (for some encodings).

    1. In Detail:

      Perl expects the source file to be encoded using ASCII (no utf8;) or UTF-8 (use utf8;).[2] That said, when expecting ASCII (no utf8;), bytes outside of ASCII in string literals produce a character with the same value in the resulting string.

      For example, say Perl expects ASCII (no utf8;) and it encounters a string literal that contains byte 80. This is illegal ASCII, but it's "€" in cp1252. Perl will produce a string that contains character 80. If you were to later print this out to a terminal expecting cp1252 (without doing any form of encoding), you'd see "€".

    2. EBCDIC machines expect EBCDIC and UTF-EBCDIC rather than ASCII and UTF-8.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-23 22:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found