in reply to Fine when written to text file, but unreadable when written to database table
So somewhere in your setup, you are storing strings in utf8, and then somewhere else, you are treating them as if they were not utf8, but rather some single-byte encoding such as iso-8859-1 or cp1252.
You haven't given us enough information to tell where the problem is. Maybe the utf8 string is contained in the web page that you fetch, and is being stored in the database as the two-byte sequence. When you read that back from the database, the two-byte utf8 character might be getting displayed "as-is" on a 8859-1 or cp1252 display, or it could be that the two bytes are each being "upgraded" to utf8 characters and you're seeing à and superscript-3 on a utf8 display.
Whatever the problem, you just need to be explicit about what encoding is being used at each step of your process, and maybe do some encoding "conversions" at appropriate points.
If the database contains utf8 strings, and you use a Perl script to read stuff back from the database, Perl probably won't be able to know automatically that the string contains utf8 "wide" characters, and you'll need to use Encode to make that explicit:
If that doesn't help, and you can't figure out what really needs to be done, you'll need to give us more information: What OS are you using, and are you using a utf8-based locale? What are you using to view the text data? Can you confirm whether the string is being stored in the database as utf8?use Encode; # assume the $string contains a value fetched from the database: $string = decode( "utf8", $string ); # sets the "utf8-flag" on $strin +g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fine when written to text file, but unreadable when written to database table
by Kanishka (Beadle) on Oct 16, 2006 at 07:59 UTC | |
by graff (Chancellor) on Oct 16, 2006 at 08:18 UTC |