jdk/test/sun/nio/cs/TestX11CNS.java
changeset 5962 0913689fd3a0
parent 5506 202f599c92aa
child 7668 d4a77089c587
equal deleted inserted replaced
5815:8c68030e27b1 5962:0913689fd3a0
    92         }
    92         }
    93         return Arrays.copyOf(cc, pos);
    93         return Arrays.copyOf(cc, pos);
    94     }
    94     }
    95 
    95 
    96     static void compare(Charset newCS, Charset oldCS) throws Exception {
    96     static void compare(Charset newCS, Charset oldCS) throws Exception {
       
    97         if (newCS == null)
       
    98             return;  // does not exist on this platform
    97         char[] cc = getChars(newCS, oldCS);
    99         char[] cc = getChars(newCS, oldCS);
    98         System.out.printf("    Diff <%s> <%s>...%n", newCS.name(), oldCS.name());
   100         System.out.printf("    Diff <%s> <%s>...%n", newCS.name(), oldCS.name());
    99 
   101 
   100         byte[] bb1 = encode(cc, newCS);
   102         byte[] bb1 = encode(cc, newCS);
   101         byte[] bb2 = encode(cc, oldCS);
   103         byte[] bb2 = encode(cc, oldCS);
   118 
   120 
   119             System.out.printf("        decoding failed%n");
   121             System.out.printf("        decoding failed%n");
   120         }
   122         }
   121     }
   123     }
   122 
   124 
       
   125     private static Charset getCharset(String czName)
       
   126         throws Exception {
       
   127         try {
       
   128             return (Charset)Class.forName(czName).newInstance();
       
   129         } catch (ClassNotFoundException e){}
       
   130         return null;  // does not exist
       
   131     }
       
   132 
   123     public static void main(String[] args) throws Exception {
   133     public static void main(String[] args) throws Exception {
   124         compare(new sun.awt.motif.X11CNS11643P1(),
   134         compare(getCharset("sun.awt.motif.X11CNS11643P1"),
   125                 new X11CNS11643P1());
   135                 new X11CNS11643P1());
   126 
   136 
   127         compare(new sun.awt.motif.X11CNS11643P2(),
   137         compare(getCharset("sun.awt.motif.X11CNS11643P2"),
   128                 new X11CNS11643P2());
   138                 new X11CNS11643P2());
   129 
   139 
   130         compare(new sun.awt.motif.X11CNS11643P3(),
   140         compare(getCharset("sun.awt.motif.X11CNS11643P3"),
   131                 new X11CNS11643P3());
   141                 new X11CNS11643P3());
   132 
   142 
   133     }
   143     }
   134 }
   144 }