I wrote Util.zip and Util.unzip methods to compress big strings, before persisting. It works fine, except when i start using chinese characters (or what i believe to be chinese).
In the simple test class below, uncommenting line 20 will add chinese characters in the test string, and make the test fail.
http://users.pandora.be/justkeys/ZipTest.java
Does anyone have any idea if this is somehow my fault, or what can be done about it.
I used sun java version 1.4.0_01-b03.
-
bug in java.util.zip.GZIPInputStream ? (3 messages)
- Posted by: Dieter Cailliau
- Posted on: July 09 2003 10:29 EDT
Threaded Messages (3)
- solved! by Dieter Cailliau on July 09 2003 10:54 EDT
- solved! by Gal Binyamini on July 09 2003 19:30 EDT
- what about .java and .jsp files by Dieter Cailliau on July 16 2003 08:43 EDT
- solved! by Gal Binyamini on July 09 2003 19:30 EDT
-
solved![ Go to top ]
- Posted by: Dieter Cailliau
- Posted on: July 09 2003 10:54 EDT
- in response to Dieter Cailliau
change
String.getBytes()
into
String.getBytes("UTF-8")
and change
new String(byte[],int,int)
into
new String(byte[],int,int,"UTF-8") -
solved![ Go to top ]
- Posted by: Gal Binyamini
- Posted on: July 09 2003 19:30 EDT
- in response to Dieter Cailliau
Just for those not familiar with the the topic of String encodings:
A string of characters can be encoded into bytes in a variety of ways. String.getBytes() uses your system's default encoding, for instance ASCII. Unless you live in Japan, your default encoding probably doesn't support japanese characters. In order to get meaningful results, you must specify an encoding that does. UTF-8 is a common example.
Gal -
what about .java and .jsp files[ Go to top ]
- Posted by: Dieter Cailliau
- Posted on: July 16 2003 08:43 EDT
- in response to Gal Binyamini
Can i use special characters in java and jsp files? For example i noticed
the euro character can be typed in eclipse, but it certainly is not surviving the jsp -> java -> class -> servlet -> runtime -> html process. So i wonder how the compiler reads jsp files (using which encoding?) and if i can change it somehow. Also important for .properties files...