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

Unsupported character encoding values (codes 129, 141, 143, 144, 157 in Cp1252)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.3.1
    • core-libs



      Name: bsC130419 Date: 06/27/2001


      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      My program reads in a string of characters from an InputStream using a
      BufferedReader. The string contains "encrypted" characters whose encoding
      is "Cp1252". The characters fall in the range of 128 to 255 and are decoded
      using a method called 'decrypt(String)' (not included). If any of the
      characters in the string have the integer encoding of 129, 141, 143, 144, or
      157, the character value is replaced (by java) with a question mark '?' and the
      integer encoding of 63. Also, I have viewed the integer values associated with
      these characters as they are read in using the method (int BufferedReader.read
      ()) and it returns an integer value of 65533 when it hits the 'unknown'
      characters.
      The characters must hold their value like any other non-displayable character.
      There is no reason to change their 'ascii' encoding value to that of another
      character. I don't care if it can't be displayed to the screen, but the
      encoding value should remain intact!!!

      Below is a short program that outputs the integer value, byte value, and string
      value for the characters in the encoding "Cp1252". This demonstrates the
      behavior that I spoke about above.

      // -----------*** Abridged Source code ***------------------
      import java.lang.*;
      import java.util.*;
      import java.io.*;
      import java.net.*;

      public class NGTest2
      {
      public static void main(String[] args)
      {
      // NOTE THIS COMMENT !!!!!!!!!!
      // This code outputs the integer values,
      // byte values, and string encoding values for the encoding type
      // of "Cp1252".
      try
      {
      for (int k=0; k < 256; k++)
      {
      byte b[] = new byte[1];
      b[0] = (byte)k;
      String str = new String(b, "Cp1252");
      System.out.println("k = " + String.valueOf(k)
      + "\t::\t" + "b = " + String.valueOf(b[0]) + "\t::\t" + "str = " + str);
      }
      }
      catch (UnsupportedEncodingException uee)
      { uee.printStackTrace(); }
      catch (Exception e)
      { e.printStackTrace();; }
      }
      }
      (Review ID: 127029)
      ======================================================================

            ilittlesunw Ian Little (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: