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

(str) Inconsistent behaviour for String.getBytes() ~'windows-31j' strings

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description



      Name: gm110360 Date: 09/28/2004


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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP Professional,
      Version 5.1.2600 Service Pack 2 Build 2600


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      japanese Local Installed, MS932 CODE Page set

      A DESCRIPTION OF THE PROBLEM :
      Inconsistent behaviour for String.getBytes() ~'windows-31j'
      /* convert from UTF-8 encoded HTML-Pages -> internal Java String Format */
      public static String convertFromUTF8(String s) {
      String out = null;
      try {
      byte []encodable = s.getBytes();
      out = new String(encodable, "windows-31j");
      byte []outBA = out.getBytes("windows-31j");
      } catch (java.io.UnsupportedEncodingException e) {
      return null;
      }

      return out;
      }

      REGRESSION. Last worked in version tiger-rc

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      just run the code supplied.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Encoding be properly handled, as was in jdk1.4.2_05
      ACTUAL -
      Garbage handling of encoding.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Logical errors.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /* convert from UTF-8 encoded HTML-Pages -> internal Java String Format */
      public static String convertFromUTF8(String s) {
      String out = null;
      try {
      byte []encodable = s.getBytes();
      out = new String(encodable, "windows-31j");
      byte []outBA = out.getBytes("windows-31j");
      } catch (java.io.UnsupportedEncodingException e) {
      return null;
      }

      return out;
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None as such
      (Incident Review ID: 311619)
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: