Skip to Content.
Sympa Menu

freetds - Re: [freetds] Problems executing a query

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Problems executing a query
  • Date: Fri, 17 Jun 2005 22:23:18 -0400

Riccardo Penco wrote:
> ZIGLIO, Frediano, VF-IT ha scritto:
> >
> > $ hexdump -C < test.php
> > 00000000 3c 3f 70 68 70 20 0a 0a 65 63 68 6f 20 27 43 69 |<?php
> > ..echo 'Ci| 00000010 74 74 c3 a0 27 3b 0a 0a 3f 3e 0a 0a
> > |tt..';..?>..|
> > 0000001c
> > $
> >
> > Note that 'à' is encoded as 0xc3 0xa0, not 0xe0.
>
> but in the php script the à is encoded as 0xe0.
>
> from the hexdump:
> 45 52 20 42 59 20 43 69 74 74 e0 3c 62 72 20 2f |ER BY Citt.<br /|
>

Right. When Frediano says "The problem is the editor", he's using some
shorthand (unless by "editor" he means a person!). On the machine where
the script is created, what answers to locale(1)?

$ locale |grep LANG
LANG="en_US.utf8"
$ hexdump -C
à
00000000 c3 a0 0a

$ locale |grep LANG
LANG="en_US.ISO8859-1"
jklowden@oak$
$ hexdump -C
à
00000000 e0 0a

Your locale setup determines how the à character is interpreted when it's
typed, and thus how it's stored in your script. It doesn't matter to
FreeTDS what encoding you use, as long as you're honest about it. If
you're not honest -- if you tell FreeTDS to expect UTF-8 when in fact the
client-side encoding is ISO 8859-1 -- then you shouldn't be surprised when
it complains. :-)

[This message arrives encoded as ISO 8859-1. If I sent is as UTF-8, I
wonder if 'à' would appear as LATIN SMALL LETTER A WITH GRAVE or as two
odd-looking characters.]

> I also noticed that if I comment out in /etc/freetds.com:
> ;client charset = UTF-8
> than the script works correctly.

If you can't be right, it's a good idea to be lucky. Your client (or at
least the script) appears to use ISO 8859-1 or similar, which is FreeTDS's
default. When you comment out the UTF-8 setting, it falls back to its
default and voilá! everything matches.

HTH.

--jkl





Archive powered by MHonArc 2.6.24.

Top of Page