libpq + utf-8

From: Лохтин Константин Сергеевич <lokhtin(at)irkutsk(dot)bnk(dot)ru>
To: <pgsql-interfaces(at)postgresql(dot)org>
Subject: libpq + utf-8
Date: 2007-08-15 01:23:08
Message-ID: C9E0F576E07259408D003079B742271D1E7919@srv14a02.bnk.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

I met problems using libpq API with utf-8 database.
I can't figure out how to use, for example, function PQexec. This function has two parameters: PQexec(PGconn *conn, const char *command);
If the command is, for example:
INSERT INTO mytable (column1,column2,column3) VALUES ('non-English text 1','non-English text 2','non-English text 3')
what format the string command[] should have? Should it be UTF-8, UTF-16 or ANSI(??) string?

When I use INSERT command with English data I can use ANSI string as command[] parameter and everything works fine, but when I try to INSERT, for example, Russian text into table columns, I fail using both UTF-8 and Windows1251 encoding in command[].

Sincerely, Konstantin S. Lokhtin,
mailto:lokhtin(at)irkutsk(dot)bnk(dot)ru, ICQ: 233336237

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Michael Fuhr 2007-08-15 03:52:15 Re: libpq + utf-8
Previous Message ustczanka 2007-08-07 17:32:19 Re: Npgsql2 Preview Release is available