Receiving unexpected character with from nvarchar field with non ASCII 8 bit character
i using sqlserver 2008 r2 , quering database through jdbc driver.
when query db through jdbc unexpected character non ascii 8 bit characters (ie > 126).
the data type of column quering nvarchar(25).
for example, value in db '0°f' query returns '0ºf'.
i  character degree symbol. if @ char values, 30 c2 b0 46, c2 char value Â. non ascii 8 bit characters have tested additional  character.
my database has support unnicode store text multiple languages japanese, chinese, european languages etc.
can explain why getting unexpected character , way prevent it.
any light thrown on issue appreciated.
ian
i don't know java can tell unicode string encoded utf-16 takes 2 bytes per character, total length of pval should 6 bytes , not 4 , individual numerical values code should have give should have been either 48 0 176 0 70 0 or 0 48 0 176 0 70 because high order byte each of these characters should 0.
in case, solution easy i've see code: string has been encoded utf-8 instead of utf-16. didn't know java capable of doing without asking it.
see: http://en.wikipedia.org/wiki/utf-8.
for rest, should check default charset (charset.defaultcharset) of java virtual machine; see:
http://docs.oracle.com/javase/6/docs/api/java/nio/charset/charset.html
btw, utf-8 valid charset used web site; don't have convert utf-16 if want display on internet.
SQL Server > SQL Server Data Access
Comments
Post a Comment