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

The ISO2022JP converter can't substitute '?' for unknown characters correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.3.0
    • 1.2.2
    • core-libs
    • kestrel
    • generic
    • generic



      Name: rlT66838 Date: 08/16/99


      The ISO2022JP converter can't substitute '?' for unknown characters correctly.

      For example, the following program output "1b 24 42 21 7b 3f 21 7b 1b 28 42".

      1b ESC
      24 $
      42 B
      21 1st byte of "WHITE CIRCLE"
      7b 2nd byte of "WHITE CIRCLE"
      3f '?' (this is a substitution character)
      21 1st byte of "WHiTE CIRCLE"
      7b 2nd byte of "WHITE CIRClE"
      1b ESC
      28 (
      42 B

      The current ISO2022JP implementation outputs a substition character without output the right escape sequence which designate ASCII to G0 when JIS X 0208 is designated to G0.

      I show the right sequence.

      1b ESC
      24 $
      42 B
      21 1st byte of "WHITE CIRCLE"
      7b 2nd byte of "WHITE CIRCLE"
      1b ESC
      28 (
      42 B
      3f '?' (this is a substitution character)
      1b ESC
      24 $
      42 B
      21 1st byte of "WHiTE CIRCLE"
      7b 2nd byte of "WHITE CIRClE"
      1b ESC
      28 (
      42 B

      And the current JDK 1.2 source distribution lacks most of character encoding converters in sun.io.
      I think that this is unfortinate for you because our japanese will contribute to you for internationalization easily if only you distribute sources of character encoding converters.

      --- sample program ---
      import java.io.UnsupportedEncodingException;

      public class circleddigit {
          public static void main(String[] args) throws UnsupportedEncodingException {
      // CIRCLED DIGHT ONE (U+2460)
      String unicode = "\u25cb\u2460\u25cb";
      byte[] b = unicode.getBytes("ISO2022JP");
      System.out.println(toHexString(b));
          }

          private static String toUnsignedString(int i, int j) {
      StringBuffer sb = new StringBuffer();
      do {
      sb.append(Character.forDigit(i & 0x0f, 16));
      i >>>= 4;
      } while (--j > 0);
      return new String(sb.reverse());
          }

          public static String toHexString(byte b) {
      return toUnsignedString((int)b, 2);
          }

          public static String toHexString(byte[] b) {
      StringBuffer sb = new StringBuffer();
      for (int i = 0; i < b.length; i++) {
      if (i > 0)
      sb.append(' ');
      sb.append(toHexString(b[i]));
      }
      return new String(sb);
          }
      }
      (Review ID: 93877)
      ======================================================================

            ktakahassunw Koushi Takahashi (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: