CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Advanced: Perl and unicode fun: Edit Log


May 11, 2009, 4:27 PM

Views: 3270
Perl and unicode fun

So I have pulled out what little hair I have left and reading and searching but have yet to find an answer to my current dilemma.

my $test = "Man\x{C3}\x{9F}earpig";
$test = decode("utf8", $test);
print qq($test\n);

simple right... no not really. This code for me will execute just fine and out put exactly what i want. the problem comes in when I try to warn $test or insert $test into a database. Doing either of these things will give me something I can not use and don't desire.

I have tried all of the following:
binmode DATA, ":utf8";
binmode STDOUT, ":utf8";
binmode STDERR, ":utf8";


binmode DATA, ":latin1";
binmode STDOUT, ":latin1";
binmode STDERR, ":latin1";

Oddly enough I have to decode with utf8 but STDOUT in latin 1 to get it to display right.

I have tried both utf8 and latin1 on my DB and the result is the same. They both give me an odd character I dont want not the odd character I do want.

I am getting Man├earpig from warn and in the DB which is bad.
i am getting Man▀earpig from print which is right.

this seems like something that should be really simple but have been trying for about 5 days now and have hit a brick wall with ideas and thoughts.

All my i18n files are right and like I said have run out of ideas. any feed back on this would be greatly appreciated. Thanks.


Edit: Alright so I was a bit tired and have realized that the:
$test = decode("utf8", $test);
is doing nothing. It is something perl internally is doing. if I change:
my $test = "Man\x{C3}\x{9F}earpig";
my $test = 'Man\x{C3}\x{9F}earpig';
The code no longer works. So it is in perls interprelation that it is making the follow string good. SO if anyone know what it is perl is doing that would be so helpful to me. Thanks again.

(This post was edited by alex_v2 on May 11, 2009, 4:48 PM)

Edit Log:
Post edited by alex_v2 (User) on May 11, 2009, 4:48 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives