[freetds] Charset question

jack brack jack.brack at inbox.com
Thu Apr 13 03:29:52 EDT 2006


> -----Original Message-----
> From: james.k.lowden at alliancebernstein.com
> Sent: Wed, 12 Apr 2006 14:07:27 -0400
> To: freetds at lists.ibiblio.org
> Subject: Re: [freetds] Charset question
> 
>> From: jack brack
>> Sent: Wednesday, April 12, 2006 11:24 AM
>> 
>>>> For this php code:
>>>>  sybase_connect($user, $pass, $serv, "iso_1")
>>>> 
>>>> Why does CT try to connect as UTF-8?
>>>> 
>>>> It does the same for this one too:
>>>> 
>>>>   sybase_connect($user, $pass, $serv, "iso-8859-1")
>>>> 
>>>> but Sybase doesn't recognise the character set.
>>> 
>>> What is it you're trying to do?
>> 
>> I'd like to connect to the server using the iso_1 character set
>> initially, without TDS trying a different character set first.
> 
> Fair enough.  :-)
> 
>> I copied my example from the lcoales.conf in cvs, which uses a
>> space:
>> 
> "http://cvs.sourceforge.net/viewcvs.py/freetds/freetds/locales.conf?rev=
> 1.5&view=markup
> 
> I know.  I think it's wrong, based on looking at the code.
> 
>>> [default]
>>>         language = english charset = iso_1
>>> 
>> 
>> I've amended my copy to match this.
>> 
>>> Turn on TDSDUMPCONFIG to confirm it's being used.

It is, but the packet dump disagrees.

TDSDUMPCONFIG says:
 option = 'client charset' value = 'iso_1'.
 tds_config_login:453: client charset is iso_1.

TDSDUMP says:
 names for ISO-8859-1: ISO-8859-1
 names for UTF-8: UTF-8
 names for UCS-2LE: UCS-2LE
 names for UCS-2BE: UCS-2BE
 iconv to convert client-side data to the "UTF-8" character set
 tds_iconv_info_init: converting "UTF-8"->"UCS-2LE"
[snip]
01c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01d0 00 0c 05 00 00 00 43 54-2d 4c 69 62 72 61 72 79 |......CT -Library|
01e0 0a 05 00 00 00 00 0d 11-65 6e 67 6c 69 73 68 00 |........ english.|
01f0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|

16:32:00.409751 Sending packet
0000 02 01 00 61 00 00 00 00-00 00 00 00 00 00 07 00 |...a.... ........|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 55 54 46 |........ .....UTF|
0020 2d 38 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |-8...... ........|
0030 00 00 00 00 00 00 00 00-00 00 00 05 01 35 31 32 |........ .....512|

So UTF-8 gets in there somehow.

Then the server replies that it doesn't recognise "UTF-8", so using iso_1.

> ...
>> So I now have a correct locales.conf file, but I'm still getting
>> a UTF-8 connection attempt.  I've verified that
> /etc/freetds/locales.conf
>> is being read using strace.
> 
> TDSDUMPCONFIG should produce this message:
> 
> 	charset is iso_1
> 
>> Any more ideas?
> 
> I don't find anywhere in the code that the LANG (or any locale
> environment variables) are affecting the login packet.  I'm not
> surprised that unsetting those didn't change anything.

If I run
 unset LANG
then the login is attempted with ANSI_X3.4-1968:

08:42:34.550614 Sending packet
0000 02 01 00 61 00 00 00 00-00 00 00 00 00 00 07 00 |...a.... ........|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 41 4e 53 |........ .....ANS|
0020 49 5f 58 33 2e 34 2d 31-39 36 38 00 00 00 00 00 |I_X3.4-1 968.....|
0030 00 00 00 00 00 00 00 00-00 00 00 0e 01 35 31 32 |........ .....512|
0040 00 00 00 03 00 00 00 00-e2 16 00 01 09 00 00 06 |........ ........|
0050 6d 7f ff ff ff fe 02 09-00 00 00 00 0a 68 00 00 |m....... .....h..|

Ack!

> 
> If you see the above message but connections continue to specify
> something else as the charset at login, then I'd guess we have a bug.
> It will take some testing with a Sybase server to track down what's
> happening.  It's been my ambition to add a bit to our debug flags to let
> login packets be logged.  It would be helpful in this case, but, well,
> enough of the subjunctive.
> 
>> No problem at all, thanks for your help.  Can I do anything to
>> update the locales.conf page in the user guide?
> 
> I'm always happy to get patches of any kind, including to the UG.  Let's
> see if we can straighten out what's going on first, though.
> 
> --jkl
> 
> -----------------------------------------
> The information contained in this transmission may be privileged and
> confidential and is intended only for the use of the person(s) named
> above. If you are not the intended recipient, or an employee or agent
> responsible
> for delivering this message to the intended recipient, any review,
> dissemination,
> distribution or duplication of this communication is strictly prohibited.
> If you are
> not the intended recipient, please contact the sender immediately by
> reply e-mail
> and destroy all copies of the original message. Please note that we do
> not accept
> account orders and/or instructions by e-mail, and therefore will not be
> responsible
> for carrying out such orders and/or instructions.  If you, as the
> intended recipient
> of this message, the purpose of which is to inform and update our
> clients, prospects
> and consultants of developments relating to our services and products,
> would not
> like to receive further e-mail correspondence from the sender, please
> "reply" to the
> sender indicating your wishes.  In the U.S.: 1345 Avenue of the Americas,
> New York,
> NY 10105.
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds



More information about the FreeTDS mailing list