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

Particular character in gb2312 charset comes as ? in IO.

XMLWordPrintable

    • x86, sparc
    • solaris_8, windows_2000



      Name: nt126004 Date: 03/11/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)


      FULL OPERATING SYSTEM VERSION :Windows 2000


      ADDITIONAL OPERATING SYSTEMS : Solaris 8



      A DESCRIPTION OF THE PROBLEM :
      Following is the test.java file.
      1. Use gb2312 or simplified chinese locale.
      2. Uncomment System.out.println step.
      3. compile the program.
      4. Run the program java -classpath relevantpaths;path to
      charsets.jar test abc
      5. You will be able to see some chinese character and abc.
      6. Copy the chinese character.
      7. comment System.out.println step
      8. Compile the program.
      9. Run the program as java -classpath relevantpaths; path to
      charsets.jar test chinese characters.
      10. You will be able to see the pattern chinese char
      chinesechar ? chinese char chinesechar.
      11. Conclusion : The middle character is not getting
      recognized by java.
      12. Both netscape 6.0 and ie5 supports this character.
          Netscape 4.7 does not support this character.


      import java.io.*;
      public class test
      {
        public void performTask(String toDisplay)
        {
              try
              {
                     
      //System.out.println("\310\313\303\361\225F\271\247\272\330");
                      OutputStreamWriter streamw =
                         new OutputStreamWriter(System.out,
      "GB2312");
                      PrintWriter out1 = new PrintWriter(streamw,
      false);
                      out1.println(toDisplay);
                      out1.flush();
              }
              catch (Exception ex)
              {}
        }

         public static void main(String[] argc)
         {

           test t = new test();
           t.performTask(argc[0]);
          }
      }


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.Following is the test.java file.
      1. Use gb2312 or simplified chinese locale.
      2. Uncomment System.out.println step.
      3. compile the program.
      4. Run the program java -classpath relevantpaths;path to
      charsets.jar test abc
      5. You will be able to see some chinese character and abc.
      6. Copy the chinese character.
      7. comment System.out.println step
      8. Compile the program.
      9. Run the program as java -classpath relevantpaths; path to
      charsets.jar test chinese characters.
      10. You will be able to see the pattern chinese char
      chinesechar ? chinese char chinesechar.
      11. Conclusion : The middle character is not getting
      recognized by java.
      12. Both netscape 6.0 and ie5 supports this character.
          Netscape 4.7 does not support this character.

      2.
      3.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Same as in system.out.println step.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;
      public class test
      {
        public void performTask(String toDisplay)
        {
              try
              {
                      //System.out.println("\310\313\303\361\225F\271\247\272\330");
                      OutputStreamWriter streamw =
                         new OutputStreamWriter(System.out, "GB2312");
                      PrintWriter out1 = new PrintWriter(streamw, false);
                      out1.println(toDisplay);
                      out1.flush();
              }
              catch (Exception ex)
              {}
        }

         public static void main(String[] argc)
         {

           test t = new test();
           t.performTask(argc[0]);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      No Work around available.
      (Review ID: 139818)
      ======================================================================

            lefan Leon Fan (Inactive)
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: