OutputStreamWriter and/or CharToByteConverter for JIS loses state

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P3
    • None
    • Affects Version/s: 1.1.4
    • Component/s: globalization



      Name: rm29839 Date: 11/12/97


      import java.io.*;

      // This program demonstrates a bug in OutputStreamWriter when using JIS

      // The correct output of this program should be
      // ESC $ B $ 4 ESC ( B ESC $ B $ _ ESC ( B
      // or something equivalent like
      // ESC $ B $ 4 $ _ ESC ( B
      // However, it outputs
      // ESC $ B $ 4 ESC ( B $ _ ESC ( B ESC ( B
      // which is erroneous.

      public class Jisbug {
        public static void main (String args[]) {
          int c;
          StringReader in;
          OutputStreamWriter out;

          try {
            in = new StringReader ("\u3054\u307f");
            out = new OutputStreamWriter (System.out, "JIS");
            while ((c=in.read()) > 0) {
              out.write (c);
            }
            in.close ();
            out.close ();
          } catch (UnsupportedEncodingException e) {
            System.err.println ("One or more unsupported encodings");
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
      (Review ID: 19524)
      ======================================================================

            Assignee:
            Xueming Shen
            Reporter:
            Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: