bug in java.util.zip.GZIPInputStream ?

Discussions

Performance and scalability: bug in java.util.zip.GZIPInputStream ?

  1. bug in java.util.zip.GZIPInputStream ? (3 messages)

    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.

    Threaded Messages (3)

  2. solved![ Go to top ]

    change

       String.getBytes()

    into

       String.getBytes("UTF-8")

    and change

       new String(byte[],int,int)

    into

       new String(byte[],int,int,"UTF-8")
  3. solved![ Go to top ]

    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
  4. 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...