Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Problem with escape sequence \x for hex with spaces "\x{ 263A }"

by Aldebaran (Curate)
on Jun 11, 2022 at 03:18 UTC ( [id://11144682]=note: print w/replies, xml ) Need Help??


in reply to Problem with escape sequence \x for hex with spaces "\x{ 263A }"

Na Rolf, I had this same failure but didn't post it, because I had *a lot* of failures and first assume that I'm doing something backwards. I can get there partially now, but I can't clear the warning:

$ perl -de1 ... DB<1> $str = "\x{ 41 }" + DB<2> p $str + DB<3> $str1 = "\x{41}" + DB<5> p $str1 + A DB<6> $str2 = "\x{263A}" + DB<7> p $str2 + Wide character in print at (eval 30)[/usr/share/perl/5.28/perl5db.pl:7 +38] line 2. ... &#9786; DB<8> binmode STDOUT, ':utf8'; + DB<9> p $str2 Wide character in print at (eval 30)[/usr/share/perl/5.28/perl5db.pl:7 +38] line 2. + ... &#9786;

I tried everything I could throw at it. Am I on STDOUT whilst invoking perl -de1 ? What am I missing?

Replies are listed 'Best First'.
Re^2: Problem with escape sequence \x for hex with spaces "\x{ 263A }"
by LanX (Saint) on Jun 11, 2022 at 05:25 UTC
    > What am I missing?

    the interactive debugger is redirecting STDOUT with every eval. You need to do it inline

    DB<3> binmode STDOUT, ':utf8'; print "\x{263A}" \u263A

    of course your terminal° must also be capable to display smileys :)

    I think if you want to change STDOUT globally for the debugger, some of the unicode flags in perlrun should do. (untested)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

    °) in my case emacs inside the console

      "I think if you want to change STDOUT globally for the debugger, some of the unicode flags in perlrun should do. (untested)"

      I tried all of these:

      $ perl -C -de1 ... $ perl -de1 ... DB<1> use open OUT => qw{:encoding(UTF-8) :std} ... $ perl -Mopen=OUT,:encoding\(UTF-8\),:std -de1 ...

      All gave the "Wide character ..." warning. All still printed "". There's probably other avenues of investigation for a global change: I didn't try anything further.

      — Ken

        I think you need to append 'O' for "Output" to the '-C'

        (my CMD-terminal has CP 850 so no emojis, sorry °)

        C:\tmp>perl -we" binmode STDOUT, ':utf8'; print qq[\x{263A}] " Ôÿ&#9553; C:\tmp>perl -CO -wde0 ... main::(-e:1): 0 DB<1> print "\x{263A}" Ôÿ&#9553; DB<2>

        UPDATE (codepage)

        °) ah found the way to change the codepage

        C:\tmp>CHCP 65001 Aktive Codepage: 65001. C:\tmp>perl -CO -wde0 ... yadda yadda ... DB<1> print "\x{263A}" &#9786; DB<2>

        PM's codeblocks are limited here², thats what I see ---> ☺ (sic)

        update (pre tags)

        ²) or with <pre><tt> tags instead

        
        C:\tmp>perl -CO -wde0
        
        ...
        
          DB<1> print "\x{263A}"
        ☺
          DB<2>
        

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

      the interactive debugger is redirecting STDOUT with every eval. You need to do it inline

      Aha...

        DB<1> binmode STDOUT, ':utf8'; print "\x{263A}"                               
      ☺
        DB<2>   
      

      Endlich erlungen. Vielen Dank....

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 21:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found