[freetds] unicode

James K. Lowden jklowden at freetds.org
Wed Jul 23 11:48:16 EDT 2008

ZIGLIO, Frediano, VF-IT wrote:
> 1> insert into #tmp1 values(N'þ')
> 2> go
> 1> select * from #tmp1
> 2> go
> c
> §
> ?
> þ
> (3 rows affected)

Wow.  I was able to reproduce that using U+0174.  (cf.
http://www.unicode.org/charts/PDF/U0100.pdf.)  I can't seem to type that
character in here; it's a W with a ^ on top.  Using Microsoft's tool, when
I insert that into an NVARCHAR without the 'N' prefix, I get a plain "W"! 

> As you can see it seems that not using N prefix string got converted
> twice, one ucs2->single and another single->ucs2 (nvarchar use ucs2).

Right.  Without the 'N' prefix, the server took perfectly good UCS-2,
converted it "down" to the database's single-byte encoding (Latin1-General
in my case), and then stored that character as UCS-2 in the NVARCHAR
column.  With the 'N', it did it right.  

In the case of my W-with-hat, there's apparently a conversion rule that
says to keep the main character and discard the "decoration" if possible. 

Thanks for helping me understand this better.  It's a little hard for me
to see it as a "feature"....



(Interestingly, on my BSD system, I see your character as 'þ' (phi?) but
on my Win32 box it appears as one character that looks like 'io' squished
together with the 'i' having a little bar across the middle. Font or
encoding, I don't know.)  

More information about the FreeTDS mailing list