in reply to Re: Bypass utf-8 encoding/decoding?
in thread Bypass utf-8 encoding/decoding?

But isn't use utf8; mandatory before calling the open pragma?

Best regards, Karl

«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

Replies are listed 'Best First'.
Re^3: Bypass utf-8 encoding/decoding?
by choroba (Cardinal) on Dec 01, 2017 at 10:04 UTC
    No. use utf8; tells Perl that the source code contains UTF-8 characters (and you can use them in identifiers, too). It's in no way related to how external data are encoded/decoded.

    ($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,

      Quite right, of course. But I was surprised today while playing with using the official name for Unicode characters to find that it's not needed in that case:

      use strict; use warnings; use feature 'say'; #use utf8; use open qw( :encoding(UTF-8) :std ); say "\N{FATHER CHRISTMAS} thanks you for all your hard work tonight"; __END__

      🎅 thanks you for all your hard work tonight
      

      use strict; use warnings; use feature 'say';
      #use utf8;
      use open qw( :encoding(UTF-8) :std );
      say "🎅 thanks you for all your hard work tonight";
      __END__
      

      🎅 thanks you for all your hard work tonight
      


      The way forward always starts with a minimal test.

        Well, spend a little time in the PerlMonks Chatterbox and you'll learn something ...

        To answer my question above, see charnames:

        "Pragma use charnames is used to gain access to the names of the Unicode characters and named character sequences ..."

        "Starting in Perl v5.16, any occurrence of \N{CHARNAME} sequences in a double-quotish string automatically loads this module ..."

        Thanks choroba for pointing to this pragma.


        The way forward always starts with a minimal test.
      "...no way related..."

      I begin to see it clearly now ;-) Thanks and best regards, Karl

      «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

Re^3: Bypass utf-8 encoding/decoding?
by ikegami (Patriarch) on Dec 01, 2017 at 16:23 UTC

    use utf8; simply tells Perl that your source code is encoded using UTF-8 (as opposed to ASCII). It would have no effect in my program.

    Furthermore, the subs provided by the module are always loaded, so I don't need to explicity load the module (use utf8 ();) to access them.

      "...no effect..."

      Yes. Thank you very much ikegami 👍. choroba already advised. Best regards, Karl

      «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

    A reply falls below the community's threshold of quality. You may see it by logging in.