in reply to Re^4: UTF-8 problem, some chars appear as \x..
in thread UTF-8 problem, some chars appear as \x..
AFAIK, MySQL returns correct UTF-8 data but doesn't set UTF-8 flag. What are other options to fix this?
Don't pass a string of char where a string of bytes is expected.
my $octets_for_mysql = decode('UTF-8', $chars); # Option 1 my $octets_for_mysql = encode('utf8', $chars); # Option 2
As for retrieving the data,
my $chars = decode('UTF-8', $octets_from_mysql); # Option 1 my $chars = decode('utf8', $octets_from_mysql); # Option 2
The difference between options 1 and 2 is explained in "UTF-8 vs. utf8" in Encode's docs.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: UTF-8 problem, some chars appear as \x..
by zanzibar (Novice) on Feb 20, 2007 at 10:06 UTC |