Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: My PerlTidy utility is choking on non-ASCII characters, help me figure out why?

by beech (Parson)
on Aug 25, 2016 at 07:37 UTC ( [id://1170387]=note: print w/replies, xml ) Need Help??


in reply to My PerlTidy utility is choking on non-ASCII characters, help me figure out why?

I can't add command-line flags like -CIO, that's not allowed.

Forget that for a moment, does it work if you add the flags?

I've tried adding binmode STDOUT, ":utf8" and binmode STDIN, ":utf8" to the BEGIN block but that hasn't changed anything.

That hints there problem isn't in perl land ... what happens if you use Data::Dumper::dd instead of print?

Replies are listed 'Best First'.
Re^2: My PerlTidy utility is choking on non-ASCII characters, help me figure out why?
by Cody Fendant (Hermit) on Aug 25, 2016 at 23:48 UTC
    Forget that for a moment, does it work if you add the flags?

    I should have been more specific. It's not allowed in the sense that the script will die with an error message "too late to add -C flag".

      oh, right, forgot about that

      What about the Dumper?

      If i try

      perl -CSD -le " print qq{use utf8;\nprint qq{I \x{2665} Perl\n};\n}; " + >foo.pl

      I get

      use utf8;
      print qq{I ♥ Perl
      };
      

      If I run that through perltidy or your program its unchanged

      cmd.exe doesn't know how to display the unicode without a chcp, but the bytes are the same

      If I add to your program

      use Data::Dump qw/pp /; print STDERR pp("$output_string");

      I get unchanged correct result as expected

      "use utf8;\nprint qq{I \xE2\x99\xA5 Perl\n};\n\n"

      by default cmd.exe does not unicode

      $ chcp
      Active code page: 437
      
      $ type foo.tdy
      use utf8;
      print qq{I ΓΦΡ Perl
      };
      
      

      If I change it I get a heart

      $ chcp 65001
      Active code page: 65001
      
      $ type foo.tdy
      use utf8;
      print qq{I ♥ Perl
      };
      

        I must be misunderstanding something, but I don't know what you're suggesting I do to actually make my code work.

        How would I use that to make a replacement for my Perl Tidy utility?

Log In?
Username:
Password:

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

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

    No recent polls found