[freetds] select bug...
Lowden, James K
LowdenJK at bernstein.com
Mon May 12 16:56:25 EDT 2003
> From: Spyros Ioakim [mailto:sioakim at atlas.ace-hellas.gr]
> Sent: May 12, 2003 1:37 PM
> First of all I see you have realised what the problem is.
> It is exactly as you describe.
> I looked at my log file and indeed wherever there is a greek character
> it is represented by a greek character.
> That is the greek letter "Pi" is not converted to english "P".
We have to very extremely specific here, lest we invite utter chaos. What
is this Pi you speak of?
What you passed to the server was =00F0. That's a number encoding a
character. I think you meant that number to represent Pi, but it doesn't.
In ISO-8859-7, http://czyborra.com/charsets/iso8859-7.txt.gz, the 8-bit
value =F0 encodes the Greek small letter Pi. UCS-2, used by your faithful
server, encodes that character with the 16-bit value U+03C0. What you sent
to the server, though, was the 16-bit value U+00F0, which happens to be the
UCS-2 encoding of the Latin small letter "Eth"
The reason FreeTDS is doing this (sending 00F0 instead of 03C0) is that it
thinks your 8-bit client data are encoded by ISO-8859-1. What you see as
Pi, it sees your =0F. Because it thinks you're using ISO-8859-1, it
understands your =F0 to be Eth, recodes it for UCS-2, and sends it along its
merry way. Lo, on the server you find Eth, not Pi. QED.
Here's a little experiment to test my theory:
1. create table T (T nchar(1))
2. /* on server */ insert T values ('p') -- Greek small letter Pi
3. /* on client */ insert T values ('p') -- Greek small letter Pi
4. select cast(T as varbinary(8)) as Hex from T
If you "select * from T" on either the client or the server, you'll see one
"right" row and one wrong one. On the server, the second row will be Eth.
On the client, the non-Pi row cannot be decoded, because FreeTDS will fail
to find a Pi character amongst the ISO-8859-1 characters it's looking in.
> My locale is all english:
What I don't understand is how your client can be set up that way and still
display Greek characters. I *guess* you can install Greek fonts and
everything sort-of Just Works?
To fix this in general, you need a Greek locale setup. To fix the
particular problem, I think you need just one line in freetds.conf:
client charset = ISO-8859-7
Well, that's enough postulation for me for one day. Let us know how it
The information contained in this transmission may contain privileged and confidential information 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.
More information about the FreeTDS