Hello DBI-users,
I'm using phpBB3 as backend for a Flash+Perl card
game in Russian language (at http://preferans.de ):
$ perl -v
This is perl, v5.8.8 built for i386-openbsd
$ psql
Welcome to psql 8.2.6, the PostgreSQL interactive terminal.
phpbb=> \l
List of databases
Name | Owner | Encoding
-----------+----------+----------
phpbb | postgres | UTF8
phpbb.OLD | postgres | UTF8
postgres | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8
When I fetch player names from the database above,
they don't seem to be recognized as UTF8:
UTF8 off, non-ASCII, 11 characters 11 bytes
UTF8 off, non-ASCII, 8 characters 8 bytes
UTF8 off, ASCII, 4 characters 4 bytes
UTF8 off, ASCII, 5 characters 5 bytes
Then I add some UTF8 data in my Perl program
(I want to log played games as posts in a forum,
so I "use utf8" and add some Russian text and also:
use constant SPADES_HTML => pack ' U', 0x2660;
use constant DIAMONDS_HTML => pack ' U', 0x2666;
use constant CLUBS_HTML => pack ' U', 0x2663;
use constant HEARTS_HTML => pack ' U', 0x2665; )
and try to store it back into the database.
Unfortunately the data is mangled unless
I call decode_utf8() on it before storing:
$game->{BODY} .= decode_utf8($user->{NAME}) . ': ' . $more_data;
Why is it so complicated? When I use PuTTY with
UTF8 encoding+Cyrillic font to login into my server
and then call psql, everything works wonderfully.
I can see the russian names, can edit them with vim...
Can't DBD::Pg recognize that it's UTF8 data?
Thank you
Alex
PS: Another thing I don't understand is that I have
to call encode_utf8 whenever I want to calculate
a checksum of UTF8 data, but that's another story?
$Sth_create_post->execute('Test 10' . SPADES_HTML,
$game->{BODY}, md5_hex(encode_utf8($game->{BODY})),