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

Re: How to print a Euro symbol () in a PerlTk Label widget.

by Ovid (Cardinal)
on Sep 04, 2012 at 15:51 UTC ( #991643=note: print w/ replies, xml ) Need Help??


in reply to How to print a Euro symbol () in a PerlTk Label widget.

If the answers above confuse you, what's going on is that the first one has this:

perl -MTk -e "tkinit->Label( -text => qq{\x{20AC}} )->pack; MainLoop;"

For that, we use \x{20AC}, the UTF-8 code for the Euro symbol and, sure enough, on my box, it displays a Label with the Euro symbol.

In the second example, the author suggests using the utf8 pragma. That's because this:

perl -MTk -e "tkinit->Label( -text => qq{} )->pack; MainLoop;"

... will probably show a Label with a bunch of funny characters because Perl doesn't realize that the symbol is a UTF-8 character, but interprets it as a byte string. The utf8 pragma tells perl (the interpreter) that your Perl (source code) is written in UTF-8 and it should show up correctly with this:

perl -MTk -e "use utf8; tkinit->Label( -text => qq{} )->pack; MainLoop;"

However, you've mentioned that you've tried both methods and they've failed to work. This implies that something else is diddling your input and output. Have you tried looking for anything else that is messing with your encodings? You could also check to see if your PERL_UNICODE environment variable has been set to something you don't expact.

You could also try utf8::all, a pragma that tries to convert all input and output to UTF-8, including noting that your source code is also UTF-8 (though this is a blunt instrument which might have side-effects if you're messing with your encodings). If you do this and you use autodie, make sure that you use at least version 2.12 of the latter as earlier versions break utf8::all.


Comment on Re: How to print a Euro symbol () in a PerlTk Label widget.
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-04-19 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (483 votes), past polls