in reply to UTF8 and Postgresql
One solution would be to simply remove all non-ASCII characters before insertion:
$text =~ s/[^\0-\x7f]//g;
Another potential option (if you have administrator privs for the db) is to change the client_encoding to something like LATIN1.
Yet another possibility is to convert your text to UTF8:
I think this last solution has a good chance of working if my theory of what's happening is correct. You'll have to check what you get out of the database when you read the data back - hopefully it will be the same as $text. If it isn't, try decoding it using decode('utf8', ...).use Encode; ... my $bytes = encode('utf8', $text); # insert $bytes instead of $text
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: UTF8 and Postgresql
by Anonymous Monk on Apr 30, 2008 at 23:05 UTC |