Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Encoding horridness revisited: What's going on here?

by choroba (Cardinal)
on Jul 13, 2017 at 09:47 UTC ( [id://1195000]=note: print w/replies, xml ) Need Help??


in reply to Encoding horridness revisited: What's going on here? [SOLVED]

In what encoding did you save the source file? What encoding does your terminal use?
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Encoding horridness revisited: What's going on here?
by karlgoethebier (Abbot) on Jul 13, 2017 at 13:59 UTC

    emacs:

    M-x describe-current-coding-system Coding system for saving this buffer: u -- mule-utf-8-unix Default coding system (for new files): u -- mule-utf-8 (alias: utf-8) Coding system for keyboard input: u -- utf-8 (alias of mule-utf-8) Coding system for terminal output: u -- utf-8 (alias of mule-utf-8) Defaults for subprocess I/O: decoding: u -- mule-utf-8 (alias: utf-8) encoding: u -- mule-utf-8 (alias: utf-8)

    bash:

    karls-mac-mini:monks karl$ locale LANG="de_DE.UTF-8" LC_COLLATE="de_DE.UTF-8" LC_CTYPE="de_DE.UTF-8" LC_MESSAGES="de_DE.UTF-8" LC_MONETARY="de_DE.UTF-8" LC_NUMERIC="de_DE.UTF-8" LC_TIME="de_DE.UTF-8" LC_ALL=

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

      Can you trust your terminal emulator to properly handle the output?

      To me, encoding issues are always a wild goose chase, so I like to eliminate as many things from the encoding dance as quickly as possible. Usually that means that instead of including umlauts (or whatever) in my source code, I use the character names instead:

      # instead of use utf8; my $s = "göre";
      # I prefer to use use charnames; my $s = "g\N{LATIN SMALL LETTER O WITH DIAERESIS}re";

      This eliminates the issue that my text editor is lying to me.

      When inspecting the output, I either pipe the output through hexdump or through Data::Dumper with $Data::Dumper::Useqq =1; so the console only sees 7bit ASCII.

      This eliminates my terminal emulator lying to me.

      Of course, that does not help with reading data from files that I don't control, but every little step helps.

        "Can you trust your terminal emulator..."

        Sure, i believe always what Apple tells me ;-)

        I continue with my investigations.

        Thanks and greetings from the Tower of Babel.

        «The Crux of the Biscuit is the Apostrophe»

        perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 10:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found