Skip to Content.
Sympa Menu

freetds - Re: [freetds] mssql_connect : Unable to connect to server

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] mssql_connect : Unable to connect to server
  • Date: Tue, 8 Nov 2005 10:57:11 -0500

> From: Pedro Barbosa
> Sent: Tuesday, November 08, 2005 6:45 AM
> James K. Lowden wrote:
> >>Frediano Ziglio wrote:
> >>>Il giorno ven, 04/11/2005 alle 16.18 +0000, Pedro Barbosa ha scritto:
> >>>when >i do a select in a table i get the tipical portuguese caracters
> >>>like a >square. how can i solve this?
> >>>
> >>>You have to use a client encoding that is compatible.
> >>>
> >Pedro Barbosa wrote:
> >>freddy can you be a litlle more specific?
> >
> >The "client charset" in freetds.conf should match the character set on the
> >client indicated by locale(1).
>
> i'm sorry but i dont think i understand.

That's OK. You provided all the information I need. :-)

> What i did was add in locales.conf
>
> [pt_PT]
> date format = %d/%m/%Y %H:%M
> language = Portuguese
> char set = iso_1

I don't think 'character set' in locales.conf is used. In any case, it would
have to be 'character set', not 'char set'. 'iso_1' is also wrong, see
below.

> and in freetds.conf i have:
>
> [server]
> host = ip port =1433 tds version = 8.0
client charset = pt_PT

No, 'client charset' in freetds.conf needs a valid iconv character set name.

> when i try to access from [freetds]/bin/tsql ....
> it says :
> locale is "pt_PT.UTF-8"
> locale charset is "UTF-8"

Good. Your locale is the Portuguese language using the UTF-8 character set.
Your client wants FreeTDS to convert characters e.g. "é ou ç ão" from the
server's encoding (iso_1, perhaps) to UTF-8.

Probably you should change your freetds.conf entry to:

[server]
host = ip
port =1433
tds version = 8.0
client charset = utf-8

Explanation follows.

FreeTDS uses iconv(3) to convert between character sets. What string does
iconv(3) expect? Usually you can use iconv(1) to determine the correct name:

$ iconv -l |grep -i utf | sed 's/^/ /'
utf-16
utf-16be
utf-16le
utf-32
utf-32be
utf-32le
utf-8 <== what you want on my box

http://www.unicode.org/standard/translations/portuguese.html

You may be used to ISO 8859-1 (latin-1) encoding, which extends ASCII in the
range 128-255. UTF-8 uses two bytes to represent non-ASCII Portuguese
characters. For example, let's look at the 'é' character:

$ locale |grep CTYPE
LC_CTYPE="en_US.ISO8859-1"

$ printf '\xe9\n'
é

That works for me because I'm *not* using UTF-8! On your machine, you should
see a little square or something.

Here it is in hex:

$ printf '\xe9\n' | hexdump -C
00000000 e9 0a

Here it is in UTF-8, in hex:

$ printf '\xe9\n' | iconv -f ISO8859-1 -t utf-8 | hexdump -C
00000000 c3 a9 0a

When your xterm is sent the 2-byte sequence 'c3a9' it prints 'é'. Let's try
it:

$ printf '\xe9\n' | iconv -f ISO8859-1 -t utf-8
é

Oops. I'm not using UTF-8. But it should work for you. ;-)

You may wish to read http://www.freetds.org/userguide/aboutunicode.htm for
some more background information.

Regards,

--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.




Archive powered by MHonArc 2.6.24.

Top of Page