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