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

Поиск
Список
Период
Сортировка
От Alexander Farber
Тема Re: convert(... using windows_1251_to_utf8) - works on cli, but not in a c prog.
Дата
Msg-id 943abd910612280151wf39f131gc1b0675434df44f0@mail.gmail.com
обсуждение исходный текст
Ответ на Re: convert(... using windows_1251_to_utf8) - works on cli, but not in a c prog.  (Alvaro Herrera <alvherre@commandprompt.com>)
Ответы Re: convert(... using windows_1251_to_utf8) - works on cli, but not in a c prog.  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-general
Hello Alvaro,

On 12/24/06, Alvaro Herrera <alvherre@commandprompt.com> wrote:
> Alexander Farber wrote:
> > I started to prepare a test case and realized I had a bug.
> > So convert() works for me, sorry for my previous message!
>
> In any case, it's probably saner if you SET client_encoding at the start
> of the session instead of using convert() everywhere.  The
> server_encoding should be correctly set to Win1251 though!  (Using
> SQL_ASCII, while not technically incorrect, is probably not doing you
> any favor).

thanks for your comment! I've dropped my db
and recreated it with encoding set to WIN1251:

pref:afarber> psql
Welcome to psql 8.1.4, the PostgreSQL interactive terminal.
.....
phpbb=> \l+
                        List of databases
   Name    |    Owner    | Encoding  |        Description
-----------+-------------+-----------+---------------------------
 phpbb     | _postgresql | WIN1251   |
 postgres  | _postgresql | SQL_ASCII |
 template0 | _postgresql | SQL_ASCII |
 template1 | _postgresql | SQL_ASCII | Default template database
(4 rows)

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

Seems to work ok... My prepared query seems to work too:

#define SQL_FETCH_USER          \
    "select convert(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)"

Regards
Alex


--
http://preferans.de

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

Предыдущее
От: "Shoaib Mir"
Дата:
Сообщение: Re: [GENERAL] 答复: [GENERAL] Need Help
Следующее
От: "Carlos H. Reimer"
Дата:
Сообщение: Improve response time of a SQL command