Re: Continuing encoding fun.... - Mailing list pgsql-odbc

From Marko Ristola
Subject Re: Continuing encoding fun....
Date
Msg-id 431DD83D.5090106@kolumbus.fi
Whole thread Raw
In response to Re: Continuing encoding fun....  (zuschlag2@online.de)
List pgsql-odbc
zuschlag2@online.de wrote:

>Hi Dave
>
>
>
>>It seems to me that the current case is correct - in the Unicode driver
>>we *must* run with client_encoding = 'UNICODE' or it won't work
>>properly. That said, I wonder if we shouldn't just remove the if()
>>altogether, and unconditionally set the client encoding for the Unicode
>>
>>

The following might be interesting for you:

If I activate ISO C 99 API, I can do the following:
( I thought, that I used ANSI C 99, but the correct name for the
standard, I meant
  is ISO C 99. It will become default later, maybe it already is with
newest GCCs.)

char cbuf[500];
wchar_t wbuf[500];

setlocale(LC_CTYPE,"");

strcpy(cbuf,"Some multibyte text");
swprintf(wbuf,"%s",cbuf);
Now the text is under wchar_t's internal format, maybe UCS-2.

The following also works:
strcpy(wbuf,L"Some UNICODE text");
sprintf(cbuf,"%ls",wbuf);

So, the UCS-2 and multibyte conversion under ISO C 99 seems to be very easy.
With GCC, with Debian Sarge, this can be done as follows:
gcc -std=c99

I don't have now more time to test, at least today.

Iconv seems to be the solution for more advanced conversions under Linux.

Regards, Marko



pgsql-odbc by date:

Previous
From: Marko Ristola
Date:
Subject: Re: savepoint
Next
From: "Scot Loach"
Date:
Subject: notice handler in libpq-based driver