Knowing the length(convert(username using windows_1251_to_utf8))

Поиск
Список
Период
Сортировка
От Alexander Farber
Тема Knowing the length(convert(username using windows_1251_to_utf8))
Дата
Msg-id 943abd910701110119x23278d0bv7f0a47cbaf001211@mail.gmail.com
обсуждение исходный текст
Ответы Re: Knowing the length(convert(username using windows_1251_to_utf8))  ("Alexander Farber" <alexander.farber@gmail.com>)
Re: Knowing the length(convert(username using windows_1251_to_utf8))  (Martijn van Oosterhout <kleptog@svana.org>)
Список 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


--
http://preferans.de

В списке pgsql-general по дате отправления:

Предыдущее
От: Ashish Karalkar
Дата:
Сообщение: Re: Foreign Key Identification
Следующее
От: Shane Ambler
Дата:
Сообщение: Re: Postgres Replication