From: | "Alexander Farber" <alexander(dot)farber(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Knowing the length(convert(username using windows_1251_to_utf8)) |
Date: | 2007-01-11 09:19:38 |
Message-ID: | 943abd910701110119x23278d0bv7f0a47cbaf001211@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Shane Ambler | 2007-01-11 09:33:17 | Re: Postgres Replication |
Previous Message | Ashish Karalkar | 2007-01-11 08:44:41 | Re: Foreign Key Identification |