Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: OT? Character set issues with MySQL/CGI::Application

by pc88mxer (Vicar)
on Jul 24, 2008 at 23:58 UTC ( #700004=note: print w/replies, xml ) Need Help??

in reply to OT? Character set issues with MySQL/CGI::Application

For a quick-n-dirty fix, try this:
# $text is the variable containing "Espaņol" from the database use Encode; $text = encode("iso-8859-1", decode("utf-8", $text)); # now print $text

Replies are listed 'Best First'.
Re^2: OT? Character set issues with MySQL/CGI::Application
by cLive ;-) (Prior) on Jul 25, 2008 at 05:22 UTC
    That does provide correct output (thanks), but does not explain why it's happening or how to resolve it correctly.

    I don't want to use a hack like that in production code. Hmmmm.

      If you can convert it from UTF-8 to Latin-1 and it then works, it means that the data you get from the data is UTF-8, and not Latin-1 as you think.

      In case of doubt print it out on the console and use hexdump to check.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://700004]
[karlgoethebier]: Discipulus: Now learn German with the Grimm Brothers...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2017-07-25 10:16 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (369 votes). Check out past polls.