convert(... using windows_1251_to_utf8) - works on cli, but not in a c prog.

From: "Alexander Farber" <alexander(dot)farber(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: convert(... using windows_1251_to_utf8) - works on cli, but not in a c prog.
Date: 2006-12-23 23:25:56
Message-ID: 943abd910612231525w5ecf342dldb83b6bf2553c1f2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I'm programming a small Flash game with PostgreSQL 8.1.4
and phpBB serving as backend. The data in the database is
in windows_1251 encoding. For my game I have to convert
it into utf8, and at the command prompt it seems to work (I recon
this because 7 win1251 chars seem to produce 14 utf8 bytes):

phpbb=> show client_encoding;
client_encoding
-----------------
SQL_ASCII
(1 row)

phpbb=> select username from phpbb_users where user_id=179;
----------
Василий
(1 row)

phpbb=> select convert(username using windows_1251_to_utf8) from
phpbb_users where user_id=179;
convert_using
----------------
Р'асилий
(1 row)

But when I call the same command from my C program,
I get the result in Windows-1251 and not in utf8:

#define SQL_FETCH_USER \
"select (username using windows_1251_to_utf8), " \
"user_avatar from phpbb_users where user_active = 1 " \
"and user_id = $1 and user_password = $2 and user_id not in " \
"(select ban_userid from phpbb_banlist where ban_userid is not null)"

PQprepare(....);
PQexecPrepared(....);

[ and as result I get only 7 bytes, in Win1251 encoding:
%C2%E0%F1%E8%EB%E8%E9 ]

I realize that my question is a bit chaotic, but maybe someone
already knows, why wouldn't convert() work in my C program?

Otherwise I'll try to prepare a simple test case

Thank you
Alex

--
http://preferans.de

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2006-12-23 23:52:53 Re: convert(... using windows_1251_to_utf8) - works on cli, but not in a c prog.
Previous Message Ben 2006-12-23 22:50:05 Re: tape backups