Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4140796
Votes 0
Synopsis ISO2022CN_CNS & ISO2022CN_GB charset not supported in BufferedReader.
Category java:char_encodings
Reported Against 1.1.2 , 1.2fcs , 1.2beta3
Release Fixed
State 11-Closed, duplicate of 4779029, bug
Priority: 4-Low
Related Bugs 4195985 , 4283282 , 4296969 , 4779029
Submit Date 21-MAY-1998
Description


ISO2022CN_CNS & ISO2022CN_GB is not supported in
the BufferedReader class. 
It is Ok for BufferedWriter.

That means that you could not read back what you write 
using the above 2 charset encoding.

Below is the ISO2022 file uses to generate a File 
with the specified encoding.

import java.io.*;
public class ISO2022 {
    public static void main (String args[]) 
    {
        String m_encoding="ISO2022CN_GB";
        String output_text="key in some chinese text here «f¿Â¨pªü";
        File  m_file = new File ("output.txt");
        
        try {
                    FileOutputStream oStream = new FileOutputStream(m_file);
                    OutputStreamWriter encode_writer = new OutputStreamWriter( oStream, m_encoding);
                    BufferedWriter      b_writer    =   new BufferedWriter(encode_writer);                        
                    b_writer.write (output_text, 0, output_text.length());
                    b_writer.flush();
                }
        catch (IOException ie)
        {
            System.out.println ("Encoding not supported!!!!!");
         }
    } //main
} // iso2022

Below is the ISOreader file which I use to read
back what I encode in "output.txt". But it throws an Exception.

mport java.io.*;
public class ISOreader{
    public static void main (String args[]) 
    {
        String m_encoding="ISO2022CN_CNS";
          File  m_file = new File ("output.txt");
        FileInputStream inStream ;
        InputStreamReader encode_reader;
        BufferedReader      b_reader  ;
        char []  cbuf =new char[100];
        String readtext;
        try {
                     inStream = new FileInputStream(m_file);
                     encode_reader = new InputStreamReader( inStream, m_encoding);

                     b_reader    =   new BufferedReader(encode_reader); 
                     if(b_reader .ready())
                     {
//                        readtext=b_reader.readLine(cbuf,0,50 );
                           b_reader.read(cbuf,0,50 );
                           readtext=new String(cbuf);
                        System.out.println( "the file contains : "+readtext);
                     }
                        if (b_reader !=null)
                            b_reader.close();
                        if (encode_reader !=null)
                             encode_reader.close();
                        if (inStream != null)
                            inStream.close();
                }
        catch (IOException ie)
        {
            System.out.println ("Encoding not supported!!!!!");
         }
        
       
    } //main
} // iso2022
(Review ID: 28804)
======================================================================
Work Around
Use the ISO2022CN converter for reading.
  xxxxx@xxxxx   1998-08-05
Evaluation
For reading, ByteToCharISO2022CN can support both ISO2022_CN and ISO2022_GB because the character sets can be recognized by the escape sequences. This is the reason why ISO2022CN_* converters are not provided for reading.
  xxxxx@xxxxx   1998-08-05

I'm closing this bug because the plan was not to provide those readers. If symmetric naming is required, please reopen this bug or file a separate request.
  xxxxx@xxxxx   1999-04-12

Well, our documentation about supported encodings doesn't distinguish between input and output. And it lists all three names. I think we need to resolve this, one way or another.
  xxxxx@xxxxx   1999-04-15


Actually there are at least two bugs in our iso2022 btc/ctb implementations
which cause iso2022 converters totally not work for CNS plane 2 & 3 with SS2 
and SS3 (we should support plane 3,4,5,6,7 too,  but it may need rewrite
the whole implementation, I think we may leave it after kestrel), see bug#4247378


  xxxxx@xxxxx   1999-06-02

A fix for this bug will be revisited for the next feature release, Tiger
  xxxxx@xxxxx   2003-01-20

Fix was already provided by means of bugIDs, 4779029 & 4737614
Should be verifiable in b28 1.5.0 (and probably earlier builds too)
  xxxxx@xxxxx   2003-11-21
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang