Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4974686

Only in 1.4.2, URLEncoder outputs exception in Japanese locale

XMLWordPrintable

    • 05
    • sparc
    • solaris_8
    • Verified

      The attached program outputs UnknownCharacterException in Japanese locale.

      REPRODUCE:

       (1) Compile the following program with -deprecation.

      ====>
      import java.io.PrintWriter;
      import java.net.*;
      import java.io.*;

      public class DecodeTests {

          final static String stringSetUTF =
              "\uD800\uDC00";

                     // a string of surrogate pairs can be expressed as 4 bytes

          /* standalone interface */
          public static void main(String argv[]) {
              String encoded = URLEncoder.encode(stringSetUTF);
          }
      }

      <===


       (2) Launch "java DecodeTests" with LANG=ja,
           then you will see the below exception.
       
      goedel[38]% java DecodeTests
      Exception in thread "main" java.lang.Error: UnknownCharacterException thrown in substititution mode
              at sun.io.CharToByteConverter.convertAny(CharToByteConverter.java:160)
              at sun.nio.cs.StreamEncoder$ConverterSE.implWrite(StreamEncoder.java:210)
              at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136)
              at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:124)
              at java.io.OutputStreamWriter.write(OutputStreamWriter.java:178)
              at java.net.URLEncoder.encode(URLEncoder.java:234)
              at java.net.URLEncoder.encode(URLEncoder.java:149)
              at DecodeTests.main(DecodeTests.java:15)
      Caused by: sun.io.UnknownCharacterException
              at sun.io.CharToByteEUC_JP_Solaris.convert(CharToByteEUC_JP_Solaris.java:97)
              at sun.io.CharToByteConverter.convertAny(CharToByteConverter.java:139)
              ... 7 more

      NOTE:

       1) Locale dependency

         If you change the locale to english, the test program seems to work well.

      goedel[39]% setenv LANG C
      goedel[40]% java DecodeTests
      goedel[41]%


       2) JDK version dependency
          This issue occurs only in 1.4.2(_0X), not in 1.4.1 and 1.5b32.


      CONFIGURATION:
        OS : SunOS goedel 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-60
        JDK : 1.4.2_02
          java version "1.4.2_02"
          Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
          Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)

      ==================================================================

            ilittlesunw Ian Little (Inactive)
            tbaba Tadayuki Baba (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: