Hello PostgreSQL users!
I have this data stored in WIN1251 encoding, which
is being fetched by a libpq application I'm developing:
phpbb=> show client_encoding;
-----------------
WIN1251
(1 row)
phpbb=> \d phpbb_users;
........
username | character varying(25) | not null default ''::character
........
phpbb=> select username, length(username), length(convert(username
using windows_1251_to_utf8)) from phpbb_users where user_id=224;
username | length | length
-----------------+--------+--------
Лукашенко И. В. | 15 | 26
(1 row)
My problem is that I need the username in the utf8 encoding.
So I use the convert(username using windows_1251_to_utf8)
which works fine except one thing:
Is there please a way to know the length of the utf8 data?
(I'm using a fixed char array in my C program)
I was using char name[25 + 1] initially, but now I see
that it isn't sufficient. Should I use char name[25 * 2 + 1] ?
How do you usually handle such cases?
Thank you for any advices
Alex
--
http://preferans.de