Re: psqlodbclibpq 8_1_03 unicode problem - Mailing list pgsql-odbc

From Marko Ristola
Subject Re: psqlodbclibpq 8_1_03 unicode problem
Date
Msg-id 42FA2EA6.7010200@kolumbus.fi
Whole thread Raw
In response to Re: psqlodbclibpq 8_1_03 unicode problem  ("Joel Fradkin" <jfradkin@wazagua.com>)
Responses Re: psqlodbclibpq 8_1_03 unicode problem
List pgsql-odbc
Characters will go into question marks, if the character conversion is
not defined
properly, or the input for the conversion functions is incorrect.


Here is something about ANSI C standard about the character conversions:


setlocale(LC_ALL,"C");
After calling this function in main() C program, the program
works as follows:

LATIN1 works with itself, because it does not need any conversions and
it is single byte
encoding.
UTF-8 works with itself, because it does not need any locale specific
information to work.

Conversion from UTF-8 into LATIN 1does not work. Non-ascii characters
will be converted
into question marks.
Conversion from LATIN1 into UTF-8 does not work. Non-ascii characters
will be converted
into question marks.

setlocale(LC_ALL,""); or setlocale(LC_CTYPE,"");

ANSI C definition for this is, that locale environment settings (Windows
settings, or Linux environment settings), for example
LC_CTYPE=fi_FI.iso8859-1 is used. This way conversions between LATIN1
and UTF-8 will work, if the environment is ANSI C compilant (it should).

So the LC_CTYPE must match with the multibyte data. Windows settings
will be activated
with the "" setting: an empty string means the environment default.

There is a good book about ANSI C 99: "The C standard"


So, how this relates to psqlodbc?

Case 1:
Typically user needs to do the conversions outside US.
Inside psqlodbc, do setlocale(LC_CTYPE,""), do the LATIN1/UTF-8 -conversion
and do setlocale(LC_CTYPE,"C");

Case 2:
Sometimes user does not want to do any charset conversions
because of performance reasons.
Don't support this one.

Case 3:
User has already done setlocale(LC_CTYPE,"");
To make Case 1 and Case 3 work, we do inside ODBC the following:
strncpy(prev_locale,setlocale(LC_CTYPE,NULL),64);
setlocale(LC_CTYPE,""), do the LATIN1/UTF-8 -conversion
and do setlocale(LC_CTYPE,prev_locale);

Case 4:
A threaded application needs to work also.
Under Windows, setlocale() can be altered to behave as thread local, so
that every
thread has it's own locale setting.
Under Linux, at least iconv() conversion facility works, even though it
is not ANSI C.


Regards, Marko Ristola



Joel Fradkin wrote:

>Not sure why your getting that.
>Is the database Unicode?
>When I was in SQLASCII mine read as ?
>The older driver 7.4 reas SQLASCII ok and presented French characters ok,
>but newer version did not.
>When I converted to a Unicode database I could read the French characters ok
>with the new driver.
>
>By the way been up Since Monday no odbc errors yet :)
>
>Joel Fradkin
>
>Wazagua, Inc.
>2520 Trailmate Dr
>Sarasota, Florida 34243
>Tel.  941-753-7111 ext 305
>
>jfradkin@wazagua.com
>www.wazagua.com
>Powered by Wazagua
>Providing you with the latest Web-based technology & advanced tools.
>© 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc
> This email message is for the use of the intended recipient(s) and may
>contain confidential and privileged information.  Any unauthorized review,
>use, disclosure or distribution is prohibited.  If you are not the intended
>recipient, please contact the sender by reply email and delete and destroy
>all copies of the original message, including attachments.
>
>
>
>
>-----Original Message-----
>From: pgsql-odbc-owner@postgresql.org
>[mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Josef Springer
>Sent: Wednesday, August 10, 2005 7:58 AM
>To: pgsql-odbc@postgresql.org
>Subject: Re: [ODBC] psqlodbclibpq 8_1_03 unicode problem
>
>I  have the same problem and reported a bug.
>It seems, that Unicode is readed unencoded (one byte per character)
>
>Josef Springer
>
>Simeó Reig wrote:
>
>
>
>>>I am using the versionde psqlodbclibpq 8_01_003, to be able to use ssl
>>>connections, and until the moment works well, but the problem has it
>>>with
>>>caracters like:
>>>
>>>character Ñ, show like character ?
>>>character ó, show like character ??
>>>
>>>that I can make?
>>>
>>>Thank you
>>>
>>>
>>I've the same problem too with spanish and catalan letters, Seems like
>>it don't support unicode characters.
>>
>>Thanks a lot
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 6: explain analyze is your friend
>>
>>
>
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: don't forget to increase your free space map settings
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: explain analyze is your friend
>
>


pgsql-odbc by date:

Previous
From: Josef Springer
Date:
Subject: Re: psqlodbclibpq 8_1_03 unicode problem
Next
From: "Mario A. Soto Cordones"
Date:
Subject: Re: psqlodbclibpq 8_1_03 unicode problem