laziness, impatience, and hubris | |
PerlMonks |
Convert special characters in UTF8by Digioso (Sexton) |
on Jun 08, 2016 at 18:17 UTC ( [id://1165163]=perlquestion: print w/replies, xml ) | Need Help?? |
Digioso has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, I've checked out a bunch of threads regarding encoding and decoding but none really described my problem. A while ago I changed my webhoster and setup a new MySQL db there which uses UTF8. I exported the old db (which didn't use UTF8) and imported it to the new db. So far the good. The problem now is that special characters (EG german ones like ä, ü, ö, ß, ...) haven't been converted properly. So now I have a database full with funny looking sentences. Example: Ein gelber dreif├â┬╝├â┼©iger Greif auf gr├â┬╝n-rotem Grund, der ein Gelds├â┬ñckchen und eine Spitzhacke h├â┬ñlt This should be: Ein gelber dreifüßiger Greif auf grün-rotem Grund, der ein Geldsäckchen und eine Spitzhacke hält What I thought: Get text from db. $text =~ s/├â┬ñ/ä/g; Repeat for all special characters. Save changed text in db. Unfortunately this doesn't work. I'm printing out the text to my screen and there is no change after the conversion. My problem right now is not a conversion between different encodings because I already am using UTF8. I need to somehow substitute the characters. But I'm probably not using the right substitutions because Perl handles those special characters different internally. My current code: The code tag seems to be having problems displaying the special characters. But I guess you get the idea.
Back to
Seekers of Perl Wisdom
|
|