Re: [Simpleweb-Support] Binary data errors on ResponseStream?
Brought to you by:
niallg
From: Nit <ni...@gm...> - 2007-07-30 20:42:06
|
Hi, if you take a look at http://de.wikipedia.org/wiki/ISO_8859-1 there are exactly 5 characters that are "greened out" in Windows-1252 all with the high byte set. So I guess this might be the encoding problem as they get converted to "?". I don't know simple very well (in fact I used it once for a project 2 years ago and stayed on the mailing list for curiosity), but I had some encoding problems lately on Tomcat myself: 1. When converting the blob to a String you can set the encoding that should be used. Have you tried to explicitly set it to ISO-8859-1? String result = new String(blob.getBytes(0, blob.length()), "ISO-8859-1"); (after reading your mail again: Does the mysql driver implicitly convert the values to String? Then this suggestion might not be helping here ...) 2. Try running your JVM with the startup parameter -Dfile.encoding=ISO-8859-1 this should set the default encoding used for such conversions. This also should apply to the mysql driver. Best Regards Martin Kai Schutte wrote: > Hi, > > This bug probably originates from a JVM encoding property issue, and a > MySQL Java driver blob conversion issue. What I didn't mention in the > below mail is that I was running Simple on my desktop WinXP machine > and I always run Tomcat on my Linux (debian) box. I was using the same > MySQL server for each. BLOB values from Mysql are converted to > Strings, so character encoding matter. The default encoding for my > debian server is ISO-8859-1, while my desktop makes the JVM use > windows-1252. I haven't fully tested this yet, cause I'm still > struggling with JVM configurations, but I'm quite sure that's the > issue. Damn windows... > > Either way, I've run a test to transfer all bytes from -127 to 128 > with a protocol handler, and it worked fine. This bug is definitely > NOT Simple related. I originally was worried because the bytes that > were getting corrupted all had their high bit set, and numerical cast > conversion in Java can be a little weird, since there's no unsigned > numerical types in Java. After digging into it more, only 5 of the 127 > negative bytes were being converted into hexadecimal 3f, so it's > obvious that wasn't the problem. > > Thanks for your reply Niall, I'll post one more reply with the full > fix once I've tested it. > > I'm looking forward to 4.0 as well =D > > Regards, > > -Kai > |