Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to sanely handle unicode in perl?

by choroba (Archbishop)
on Mar 20, 2015 at 16:26 UTC ( #1120762=note: print w/replies, xml ) Need Help??


in reply to How to sanely handle unicode in perl?

If "the right thing" is to accept UTF-8 whatever the locale is, don't count on locale. Modify line 6 to
use open 'utf8', ':std';
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: How to sanely handle unicode in perl?
by Sec (Monk) on Mar 20, 2015 at 16:38 UTC
    That does not work. It has the same effect as commenting out the "use open" line. Try it in an UTF-8 terminal with LC_CTYPE set properly to utf-8. The print to STDOUT corrupts the character.
    karoshi:~>LC_CTYPE=de_DE.UTF-8 ./u8demo.pl I read a line, that is 1 chars long. That line is: � That line in ascii is: o

      You took the locale bit out, right? Both examples from choroba and me/tchrist work in my UTF-8 terminal.

      moo@cow~>echo $LC_CTYPE
      utf-8
      moo@cow~>perl ~/pm-eg
      I read a line, that is 1 chars long.
      That line is: 
      That line in ascii is: o
      

      Update: this works the same for me as well: setenv LC_CTYPE de_DE.UTF-8

        As said elsewhere, I've not found a way to make it work in both UTF-8 and ISO8859-1 terminals. Not looking at the locale charset to see what terminal you are on does not sound like it'll work.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2022-01-21 21:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (59 votes). Check out past polls.

    Notices?