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

Codepage aliases for EURO codepages missing

XMLWordPrintable

    • 05
    • generic, sparc
    • generic, solaris_8
    • Verified

        Name: ddT132432 Date: 08/20/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)

        When trying to use the character conversion class ByteToCharCp1141 and other
        EURO codepages (like 1140, 1142 etc.) one has to use codepage name "Cp1141". It
        is not possible to use solely "1141" like with pages "500" or "273". I suppose,
        this is due to some missing aliases in class CharacterConversion's private
        aliasTable Hashtable.
        The main problem is, that conversion between Windows codepages and EDBCIC
        codepage 1141, which is used on our IBM host does not work correctly using the
        IBM provided JMS implementation classes. I already submitted this bug to IBM,
        but I think a better fix for the problem would be, to simply include an alias
        for "Cp1141" in above mentioned class. There are already similar aliases for
        other EDBCIC pages like "Cp273" and "Cp500".

        The following class shows the problem by listing the supported codepages and
        their aliases (if present):

        import java.util.*;
        public class EncodingTest
        {
            public static void main(String[] args)
            {
                int i;
                int max = 6000;
                if(args.length == 1)
                    max = Integer.parseInt(args[0]) + 1;

                byte[] bytes = { (byte) 'h', (byte) 'e', (byte) 'l', (byte) 'l', (byte) 'o' };
                String enc, cpenc, cp2enc, string, alias=null;
                System.out.println("EncodingTest Start " + new Date());
                System.out.println("\n\n System properties ");
                System.out.println("\n\n ================= ");
                Properties p = System.getProperties();
                p.list(System.out);
                System.out.println("\n\n Memory usage ");
                System.out.println("\n\n ============ ");
                Runtime rt = Runtime.getRuntime();
                System.out.println(" Total Memory = " + rt.totalMemory() +
                                   " Free Memory = " + rt.freeMemory());
                System.out.println("\n\n Code page support ");
                System.out.println("\n\n ================= ");
                for(i = 0; i < max; i++)
                {
                    enc = String.valueOf(i);

                    cp2enc="";
        try
                    {
                        string = new String(bytes, enc);
                        System.out.println(" Encoding " + enc + " is supported");
        alias = sun.io.CharacterEncoding.aliasName(enc);
        if ( alias != null )
        System.out.println("Alias for encoding "+enc+": "+alias);
                    }
                    catch(java.io.UnsupportedEncodingException e)
                    {
        alias = sun.io.CharacterEncoding.aliasName(enc);
        if ( alias != null )
        System.out.println("Alias for encoding "+enc+": "+alias);
        }
        //System.out.println(" Encoding "+enc+" is unsupported");
        /**
        Now try to encode the string using the codepage no. prepended with
        "Cp" to find out whether the codepage is supported using its IANA name
        */
        try {
        cpenc = "Cp"+enc;
        string = new String(bytes, cpenc);
        System.out.println(" Encoding " + cpenc + " is supported");
        alias = sun.io.CharacterEncoding.aliasName(cpenc);
        if ( alias != null )
        System.out.println("Alias for encoding "+cpenc+": "+alias);
        try {
        cp2enc = "CP"+enc;
        string = new String(bytes, cp2enc);
        System.out.println(" Encoding " + cp2enc + " is supported");
        alias = sun.io.CharacterEncoding.aliasName(cp2enc);
        if ( alias != null )
        System.out.println("Alias for encoding "+cp2enc+": "+alias);
        }catch(java.io.UnsupportedEncodingException ue2){
        System.out.println(" Encoding "+cp2enc+" is unsupported");
        }
        }catch(java.io.UnsupportedEncodingException ue){
        //System.out.println(" Encoding "+enc+" is unsupported");
        }

                 }

                System.out.println("\n\nEncodingTest End");

            }
        }
        (Review ID: 130296)
        ======================================================================

              ilittlesunw Ian Little (Inactive)
              ddressersunw Daniel Dresser (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: