Обсуждение: Unicode conversion issue

Поиск
Список
Период
Сортировка

Unicode conversion issue

От
Al Cohen
Дата:
We have a PostgreSQL database in Unicode that I'm trying to read into a
C# application.  In theory, the easiest thing to do would be to use the
Beta ODBC Unicode driver or one of the .NET data providers for
PostgreSQL, but these seem to be fairly immature.

So, I'm hoping to use the standard ODBC driver, which seems quite
mature, to read and write to a Unicode database.  Can this be done by
properly decoding and encoding?

For starters, I'm wondering if someone can help me to understand just
what the standard psqlODBC is returning to my C# application when I read
a unicode string?  The ASCII characters (<128)  are returning as ASCII
characters, but the higher characters are turning into 4 unicode
characters, or 8 bytes.  My initial thought was that this was UTF-8, but
UTF-8 is maximum 6 bytes.

Re: Unicode conversion issue

От
Benjamin Riefenstahl
Дата:
Hi Al,


Al Cohen <amc79@no.junk.please.cornell.edu> writes:
> For starters, I'm wondering if someone can help me to understand
> just what the standard psqlODBC is returning to my C# application
> when I read a unicode string?

From the PostgreSQL side I use the statement

  SET CLIENT_ENCODING TO 'UNICODE'

just after connection to tell it to give me UTF-8.  You could use
other encodings, see the documentation.

From the other side I don't know that C# expects here, you'd have to
check its ODBC bindings.  It may expect the local 8-bit codepage by
default.


benny