On 2008.04.17, Dossy Shiobara <[EMAIL PROTECTED]> wrote:
> > 1.1.2 Pasting some Chinese characters via SQL Server Management
> > Studio Express
>
> I used this, which I hope is equivalent to your Java program:
>
> INSERT INTO multibytetest (value)
> SELECT CHAR(230) + CHAR(144) + CHAR(156) + CHAR(231) + CHAR(139) +
> CHAR(144) + CHAR(231) + CHAR(132) + CHAR(166) + CHAR(231) +
> CHAR(130) + CHAR(185) + CHAR(229) + CHAR(155) + CHAR(190) +
> CHAR(230) + CHAR(150) + CHAR(176) + CHAR(233) + CHAR(151) +
> CHAR(187)
>
> Would you mind confirming if this inserts data identical to what your
> Java program does? Thanks.
I just got sqljdbc.jar and ran the InsertMultibyte.java and it does NOT
insert what I inserted above. (Oops.) The correct SQL equivalent would
be:
INSERT INTO multibytetest (value)
SELECT NCHAR(0x641C) + NCHAR(0x72D0) + NCHAR(0x7126) +
NCHAR(0x70B9) + NCHAR(0x56FE) + NCHAR(0x65B0) +
NCHAR(0x95FB)
How did I come up with that? From the original UTF-8 bytes in your Java
program, with this little Tcl snippet:
set x {
-26 -112 -100
-25 -117 -112
-25 -124 -90
-25 -126 -71
-27 -101 -66
-26 -106 -80
-23 -105 -69
}
set y [encoding convertfrom utf-8 [binary format c* $x]]; return
set z [encoding convertto unicode $y]; return
binary scan $z c* a
foreach {n m} $a {
puts [format "NCHAR(0x%02X%02X)" [expr $m & 0xFF] [expr $n & 0xFF]]
}
That can be pasted directly into a tclsh. Note the transcoding from
UTF-8 to Unicode, as SQL Server uses Unicode (UCS-2) encoding.
With this test data and my changes to nsfreetds, and the server
configuration set to "text/html; charset=GB2312" ... I can now retrieve
the Chinese characters and see them rendered in the browser like this:
http://dossy.org/images/aolserver-nsfreetds-gb2312-2.png
Sadly, I have no idea what it says or if it's actually correct ... but
it looks like reasonable Chinese to me.
Overall, it looks like my changes to nsfreetds may have worked ...
although I would really appreciate more rigorous testing from folks out
there who use nsfreetds. Any volunteers?
I'm going to commit my changes so far and once more folks test and
verify that everything works, I'll tag a release of nsfreetds.
--
Dossy Shiobara | [EMAIL PROTECTED] | http://dossy.org/
Panoptic Computer Network | http://panoptic.com/
"He realized the fastest way to change is to laugh at your own
folly -- then you can let go and quickly move on." (p. 70)
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]>
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.