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

Inconsistent char-to-byte translation of 0x8e and 0x93

XMLWordPrintable

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



      Name: rlT66838 Date: 04/27/2000


      java version "1.3beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1
      Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)

      1. Create input file (e.g., c:\datain.txt) containing characters with byte
         values 0x0080 through 0x00FD

      2. Run following on 1.3 (beta) and 1.2 using same input file:

      //BEGIN CODE ************************************
      import java.io.*;

      public class test {
        public static void main(String[] args) throws IOException {
          final FileReader inputFile = new FileReader("C:\\datain.txt");
          final FileOutputStream outputFile = new FileOutputStream("C:\\dataout.txt");
          final BufferedReader reader = new BufferedReader(inputFile);
          final DataOutputStream writer = new DataOutputStream(outputFile);
          String line;
          char[] chars;
          int hexIn = 0x0080;
          writer.writeBytes("FileReader Encoding = " + inputFile.getEncoding() +
      "\r\n");
          try {
             while ((line = reader.readLine()) != null) {
                chars = line.toCharArray();
                for(int i = 0;i < chars.length;i++) {
                  writer.writeBytes(Integer.toHexString(hexIn++) + " -> " + chars[i] +
      " (" + Integer.toHexString((int) chars[i]) + ") ");
                  writer.writeBytes("\r\n");
                } // end of for ...
              } // end of while ...
          } // end of try
          finally {
               reader.close();
               writer.close();
          } // end of finally
        } // end of main
      } // end of class
      //END CODE ************************************

      3. Compare output for characters 0x008e and 0x009e. The following output
         generated with FileReader Encoding = Cp1252.

         1.3 1.2
         ------------- --------------
         8e -> } (17d) 8e -> ý (fffd)
         9e -> ~ (17e) 9e -> ý (fffd)
      (Review ID: 104204)
      ======================================================================

            ilittlesunw Ian Little (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: