Re: Continuing encoding fun....

From: Marko Ristola <Marko(dot)Ristola(at)kolumbus(dot)fi>
To:
Cc: pgsql-odbc(at)postgresql(dot)org
Subject: Re: Continuing encoding fun....
Date: 2005-09-06 17:56:13
Message-ID: 431DD83D.5090106@kolumbus.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

zuschlag2(at)online(dot)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

In response to

Browse pgsql-odbc by date

  From Date Subject
Next Message Scot Loach 2005-09-06 18:18:22 notice handler in libpq-based driver
Previous Message Marko Ristola 2005-09-06 16:53:43 Re: savepoint