1 /* 2 * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 4625418 27 * @summary Tests XML <a href="http://download.java.net/jdk6/docs/technotes/guides/intl/encoding.doc.html">encoding</a> 28 * @author Sergey Malenkov 29 * 30 * @run main Test4625418 ASCII 31 * @run main Test4625418 Big5 32 * ?run main Test4625418 Big5-HKSCS 33 * ?run main Test4625418 Big5_HKSCS 34 * @run main Test4625418 Big5_Solaris 35 * ?run main Test4625418 Cp037 36 * @run main Test4625418 Cp1006 37 * ?run main Test4625418 Cp1025 38 * -run main Test4625418 Cp1026 39 * @run main Test4625418 Cp1046 40 * @run main Test4625418 Cp1047 41 * @run main Test4625418 Cp1097 42 * @run main Test4625418 Cp1098 43 * ?run main Test4625418 Cp1112 44 * ?run main Test4625418 Cp1122 45 * ?run main Test4625418 Cp1123 46 * @run main Test4625418 Cp1124 47 * ?run main Test4625418 Cp1140 48 * ?run main Test4625418 Cp1141 49 * ?run main Test4625418 Cp1142 50 * ?run main Test4625418 Cp1143 51 * ?run main Test4625418 Cp1144 52 * ?run main Test4625418 Cp1145 53 * ?run main Test4625418 Cp1146 54 * ?run main Test4625418 Cp1147 55 * ?run main Test4625418 Cp1148 56 * ?run main Test4625418 Cp1149 57 * @run main Test4625418 Cp1250 58 * @run main Test4625418 Cp1251 59 * @run main Test4625418 Cp1252 60 * @run main Test4625418 Cp1253 61 * @run main Test4625418 Cp1254 62 * @run main Test4625418 Cp1255 63 * @run main Test4625418 Cp1256 64 * @run main Test4625418 Cp1257 65 * @run main Test4625418 Cp1258 66 * ?run main Test4625418 Cp1381 67 * ?run main Test4625418 Cp1383 68 * ?run main Test4625418 Cp273 69 * ?run main Test4625418 Cp277 70 * ?run main Test4625418 Cp278 71 * ?run main Test4625418 Cp280 72 * ?run main Test4625418 Cp284 73 * ?run main Test4625418 Cp285 74 * ?run main Test4625418 Cp297 75 * ?run main Test4625418 Cp33722 76 * ?run main Test4625418 Cp420 77 * ?run main Test4625418 Cp424 78 * @run main Test4625418 Cp437 79 * ?run main Test4625418 Cp500 80 * ?run main Test4625418 Cp50220 81 * ?run main Test4625418 Cp50221 82 * @run main Test4625418 Cp737 83 * @run main Test4625418 Cp775 84 * -run main Test4625418 Cp834 85 * ?run main Test4625418 Cp838 86 * @run main Test4625418 Cp850 87 * @run main Test4625418 Cp852 88 * @run main Test4625418 Cp855 89 * @run main Test4625418 Cp856 90 * @run main Test4625418 Cp857 91 * @run main Test4625418 Cp858 92 * @run main Test4625418 Cp860 93 * @run main Test4625418 Cp861 94 * @run main Test4625418 Cp862 95 * @run main Test4625418 Cp863 96 * @run main Test4625418 Cp864 97 * @run main Test4625418 Cp865 98 * @run main Test4625418 Cp866 99 * @run main Test4625418 Cp868 100 * @run main Test4625418 Cp869 101 * ?run main Test4625418 Cp870 102 * ?run main Test4625418 Cp871 103 * @run main Test4625418 Cp874 104 * ?run main Test4625418 Cp875 105 * ?run main Test4625418 Cp918 106 * @run main Test4625418 Cp921 107 * @run main Test4625418 Cp922 108 * -run main Test4625418 Cp930 109 * @run main Test4625418 Cp933 110 * ?run main Test4625418 Cp935 111 * ?run main Test4625418 Cp937 112 * ?run main Test4625418 Cp939 113 * ?run main Test4625418 Cp942 114 * ?run main Test4625418 Cp942C 115 * @run main Test4625418 Cp943 116 * ?run main Test4625418 Cp943C 117 * @run main Test4625418 Cp948 118 * @run main Test4625418 Cp949 119 * ?run main Test4625418 Cp949C 120 * @run main Test4625418 Cp950 121 * @run main Test4625418 Cp964 122 * ?run main Test4625418 Cp970 123 * ?run main Test4625418 EUC-JP 124 * @run main Test4625418 EUC-KR 125 * @run main Test4625418 EUC_CN 126 * ?run main Test4625418 EUC_JP 127 * ?run main Test4625418 EUC_JP_LINUX 128 * ?run main Test4625418 EUC_JP_Solaris 129 * @run main Test4625418 EUC_KR 130 * ?run main Test4625418 EUC_TW 131 * @run main Test4625418 GB18030 132 * @run main Test4625418 GB2312 133 * @run main Test4625418 GBK 134 * ?run main Test4625418 IBM-Thai 135 * @run main Test4625418 IBM00858 136 * ?run main Test4625418 IBM01140 137 * ?run main Test4625418 IBM01141 138 * ?run main Test4625418 IBM01142 139 * ?run main Test4625418 IBM01143 140 * ?run main Test4625418 IBM01144 141 * ?run main Test4625418 IBM01145 142 * ?run main Test4625418 IBM01146 143 * ?run main Test4625418 IBM01147 144 * ?run main Test4625418 IBM01148 145 * ?run main Test4625418 IBM01149 146 * ?run main Test4625418 IBM037 147 * -run main Test4625418 IBM1026 148 * @run main Test4625418 IBM1047 149 * ?run main Test4625418 IBM273 150 * ?run main Test4625418 IBM277 151 * ?run main Test4625418 IBM278 152 * ?run main Test4625418 IBM280 153 * ?run main Test4625418 IBM284 154 * ?run main Test4625418 IBM285 155 * ?run main Test4625418 IBM297 156 * ?run main Test4625418 IBM420 157 * ?run main Test4625418 IBM424 158 * @run main Test4625418 IBM437 159 * ?run main Test4625418 IBM500 160 * @run main Test4625418 IBM775 161 * @run main Test4625418 IBM850 162 * @run main Test4625418 IBM852 163 * @run main Test4625418 IBM855 164 * @run main Test4625418 IBM857 165 * @run main Test4625418 IBM860 166 * @run main Test4625418 IBM861 167 * @run main Test4625418 IBM862 168 * @run main Test4625418 IBM863 169 * @run main Test4625418 IBM864 170 * @run main Test4625418 IBM865 171 * @run main Test4625418 IBM866 172 * @run main Test4625418 IBM868 173 * @run main Test4625418 IBM869 174 * ?run main Test4625418 IBM870 175 * ?run main Test4625418 IBM871 176 * ?run main Test4625418 IBM918 177 * ?run main Test4625418 ISCII91 178 * -run main Test4625418 ISO-2022-CN 179 * @run main Test4625418 ISO-2022-JP 180 * @run main Test4625418 ISO-2022-KR 181 * @run main Test4625418 ISO-8859-1 182 * @run main Test4625418 ISO-8859-13 183 * @run main Test4625418 ISO-8859-15 184 * @run main Test4625418 ISO-8859-2 185 * @run main Test4625418 ISO-8859-3 186 * @run main Test4625418 ISO-8859-4 187 * @run main Test4625418 ISO-8859-5 188 * @run main Test4625418 ISO-8859-6 189 * @run main Test4625418 ISO-8859-7 190 * @run main Test4625418 ISO-8859-8 191 * @run main Test4625418 ISO-8859-9 192 * -run main Test4625418 ISO2022CN 193 * @run main Test4625418 ISO2022JP 194 * @run main Test4625418 ISO2022KR 195 * -run main Test4625418 ISO2022_CN_CNS 196 * -run main Test4625418 ISO2022_CN_GB 197 * @run main Test4625418 ISO8859_1 198 * @run main Test4625418 ISO8859_13 199 * @run main Test4625418 ISO8859_15 200 * @run main Test4625418 ISO8859_2 201 * @run main Test4625418 ISO8859_3 202 * @run main Test4625418 ISO8859_4 203 * @run main Test4625418 ISO8859_5 204 * @run main Test4625418 ISO8859_6 205 * @run main Test4625418 ISO8859_7 206 * @run main Test4625418 ISO8859_8 207 * @run main Test4625418 ISO8859_9 208 * -run main Test4625418 JISAutoDetect 209 * ?run main Test4625418 JIS_X0201 210 * -run main Test4625418 JIS_X0212-1990 211 * @run main Test4625418 KOI8-R 212 * @run main Test4625418 KOI8-U 213 * @run main Test4625418 KOI8_R 214 * @run main Test4625418 KOI8_U 215 * @run main Test4625418 MS874 216 * ?run main Test4625418 MS932 217 * ?run main Test4625418 MS936 218 * @run main Test4625418 MS949 219 * @run main Test4625418 MS950 220 * ?run main Test4625418 MS950_HKSCS 221 * @run main Test4625418 MacArabic 222 * @run main Test4625418 MacCentralEurope 223 * @run main Test4625418 MacCroatian 224 * @run main Test4625418 MacCyrillic 225 * -run main Test4625418 MacDingbat 226 * @run main Test4625418 MacGreek 227 * @run main Test4625418 MacHebrew 228 * @run main Test4625418 MacIceland 229 * @run main Test4625418 MacRoman 230 * @run main Test4625418 MacRomania 231 * -run main Test4625418 MacSymbol 232 * @run main Test4625418 MacThai 233 * @run main Test4625418 MacTurkish 234 * @run main Test4625418 MacUkraine 235 * ?run main Test4625418 PCK 236 * ?run main Test4625418 SJIS 237 * ?run main Test4625418 Shift_JIS 238 * @run main Test4625418 TIS-620 239 * @run main Test4625418 TIS620 240 * @run main Test4625418 US-ASCII 241 * @run main Test4625418 UTF-16 242 * @run main Test4625418 UTF-16BE 243 * @run main Test4625418 UTF-16LE 244 * @run main Test4625418 UTF-32 245 * @run main Test4625418 UTF-32BE 246 * @run main Test4625418 UTF-32LE 247 * @run main Test4625418 UTF-8 248 * @run main Test4625418 UTF8 249 * @run main Test4625418 UTF_32 250 * @run main Test4625418 UTF_32BE 251 * -run main Test4625418 UTF_32BE_BOM 252 * @run main Test4625418 UTF_32LE 253 * -run main Test4625418 UTF_32LE_BOM 254 * @run main Test4625418 UnicodeBig 255 * @run main Test4625418 UnicodeBigUnmarked 256 * @run main Test4625418 UnicodeLittle 257 * @run main Test4625418 UnicodeLittleUnmarked 258 * @run main Test4625418 windows-1250 259 * @run main Test4625418 windows-1251 260 * @run main Test4625418 windows-1252 261 * @run main Test4625418 windows-1253 262 * @run main Test4625418 windows-1254 263 * @run main Test4625418 windows-1255 264 * @run main Test4625418 windows-1256 265 * @run main Test4625418 windows-1257 266 * @run main Test4625418 windows-1258 267 * ?run main Test4625418 windows-31j 268 * -run main Test4625418 x-Big5_Solaris 269 * ?run main Test4625418 x-EUC-TW 270 * @run main Test4625418 x-IBM1006 271 * ?run main Test4625418 x-IBM1025 272 * @run main Test4625418 x-IBM1046 273 * @run main Test4625418 x-IBM1097 274 * @run main Test4625418 x-IBM1098 275 * ?run main Test4625418 x-IBM1112 276 * ?run main Test4625418 x-IBM1122 277 * ?run main Test4625418 x-IBM1123 278 * @run main Test4625418 x-IBM1124 279 * ?run main Test4625418 x-IBM1381 280 * ?run main Test4625418 x-IBM1383 281 * ?run main Test4625418 x-IBM33722 282 * @run main Test4625418 x-IBM737 283 * -run main Test4625418 x-IBM834 284 * @run main Test4625418 x-IBM856 285 * @run main Test4625418 x-IBM874 286 * ?run main Test4625418 x-IBM875 287 * @run main Test4625418 x-IBM921 288 * @run main Test4625418 x-IBM922 289 * -run main Test4625418 x-IBM930 290 * @run main Test4625418 x-IBM933 291 * ?run main Test4625418 x-IBM935 292 * ?run main Test4625418 x-IBM937 293 * ?run main Test4625418 x-IBM939 294 * ?run main Test4625418 x-IBM942 295 * ?run main Test4625418 x-IBM942C 296 * @run main Test4625418 x-IBM943 297 * ?run main Test4625418 x-IBM943C 298 * @run main Test4625418 x-IBM948 299 * @run main Test4625418 x-IBM949 300 * ?run main Test4625418 x-IBM949C 301 * @run main Test4625418 x-IBM950 302 * @run main Test4625418 x-IBM964 303 * ?run main Test4625418 x-IBM970 304 * ?run main Test4625418 x-ISCII91 305 * -run main Test4625418 x-ISO2022-CN-CNS 306 * -run main Test4625418 x-ISO2022-CN-GB 307 * -run main Test4625418 x-JIS0208 308 * -run main Test4625418 x-JISAutoDetect 309 * @run main Test4625418 x-Johab 310 * ?run main Test4625418 x-MS950-HKSCS 311 * @run main Test4625418 x-MacArabic 312 * @run main Test4625418 x-MacCentralEurope 313 * @run main Test4625418 x-MacCroatian 314 * @run main Test4625418 x-MacCyrillic 315 * -run main Test4625418 x-MacDingbat 316 * @run main Test4625418 x-MacGreek 317 * @run main Test4625418 x-MacHebrew 318 * @run main Test4625418 x-MacIceland 319 * @run main Test4625418 x-MacRoman 320 * @run main Test4625418 x-MacRomania 321 * -run main Test4625418 x-MacSymbol 322 * @run main Test4625418 x-MacThai 323 * @run main Test4625418 x-MacTurkish 324 * @run main Test4625418 x-MacUkraine 325 * ?run main Test4625418 x-PCK 326 * @run main Test4625418 x-UTF-16LE-BOM 327 * -run main Test4625418 x-UTF-32BE-BOM 328 * -run main Test4625418 x-UTF-32LE-BOM 329 * ?run main Test4625418 x-euc-jp-linux 330 * ?run main Test4625418 x-eucJP-Open 331 * @run main Test4625418 x-iso-8859-11 332 * @run main Test4625418 x-mswin-936 333 * ?run main Test4625418 x-windows-50220 334 * ?run main Test4625418 x-windows-50221 335 * @run main Test4625418 x-windows-874 336 * @run main Test4625418 x-windows-949 337 * @run main Test4625418 x-windows-950 338 * ?run main Test4625418 x-windows-iso2022jp 339 */ 340 341 import java.beans.ExceptionListener; 342 import java.beans.XMLDecoder; 343 import java.beans.XMLEncoder; 344 import java.io.File; 345 import java.io.FileInputStream; 346 import java.io.FileNotFoundException; 347 import java.io.FileOutputStream; 348 import java.nio.charset.IllegalCharsetNameException; 349 import java.nio.charset.UnsupportedCharsetException; 350 351 public final class Test4625418 implements ExceptionListener { 352 public static void main(String[] args) { 353 new Test4625418(args[0]).test(createString(0x10000)); 354 System.out.println("Test passed: " + args[0]); 355 } 356 357 private static String createString(int length) { 358 StringBuilder sb = new StringBuilder(length); 359 while (0 < length--) 360 sb.append((char) length); 361 362 return sb.toString(); 363 } 364 365 private final String encoding; 366 367 private Test4625418(String encoding) { 368 this.encoding = encoding; 369 } 370 371 private void test(String string) { 372 try { 373 File file = new File("4625418." + this.encoding + ".xml"); 374 375 FileOutputStream output = new FileOutputStream(file); 376 XMLEncoder encoder = new XMLEncoder(output, this.encoding, true, 0); 377 encoder.setExceptionListener(this); 378 encoder.writeObject(string); 379 encoder.close(); 380 381 FileInputStream input = new FileInputStream(file); 382 XMLDecoder decoder = new XMLDecoder(input); 383 decoder.setExceptionListener(this); 384 Object object = decoder.readObject(); 385 decoder.close(); 386 387 if (!string.equals(object)) 388 throw new Error(this.encoding + " - can't read properly"); 389 390 file.delete(); 391 } 392 catch (FileNotFoundException exception) { 393 throw new Error(this.encoding + " - file not found", exception); 394 } 395 catch (IllegalCharsetNameException exception) { 396 throw new Error(this.encoding + " - illegal charset name", exception); 397 } 398 catch (UnsupportedCharsetException exception) { 399 throw new Error(this.encoding + " - unsupported charset", exception); 400 } 401 catch (UnsupportedOperationException exception) { 402 throw new Error(this.encoding + " - unsupported encoder", exception); 403 } 404 } 405 406 public void exceptionThrown(Exception exception) { 407 throw new Error(this.encoding + " - internal", exception); 408 } 409 } | 1 /* 2 * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 4625418 27 * @summary Tests XML <a href="http://download.java.net/jdk6/docs/technotes/guides/intl/encoding.doc.html">encoding</a> 28 * @author Sergey Malenkov 29 * @run main/timeout=360 Test4625418 30 */ 31 32 import java.beans.ExceptionListener; 33 import java.beans.XMLDecoder; 34 import java.beans.XMLEncoder; 35 import java.io.ByteArrayInputStream; 36 import java.io.ByteArrayOutputStream; 37 import java.io.InputStream; 38 import java.nio.charset.IllegalCharsetNameException; 39 import java.nio.charset.UnsupportedCharsetException; 40 41 public final class Test4625418 implements ExceptionListener { 42 43 private static final String[] encodings = { 44 "ASCII", 45 "Big5", 46 //"Big5-HKSCS", 47 //"Big5_HKSCS", 48 "Big5_Solaris", 49 //"Cp037", 50 "Cp1006", 51 //"Cp1025", 52 //"Cp1026", 53 "Cp1046", 54 "Cp1047", 55 "Cp1097", 56 "Cp1098", 57 //"Cp1112", 58 //"Cp1122", 59 //"Cp1123", 60 "Cp1124", 61 //"Cp1140", 62 //"Cp1141", 63 //"Cp1142", 64 //"Cp1143", 65 //"Cp1144", 66 //"Cp1145", 67 //"Cp1146", 68 //"Cp1147", 69 //"Cp1148", 70 //"Cp1149", 71 "Cp1250", 72 "Cp1251", 73 "Cp1252", 74 "Cp1253", 75 "Cp1254", 76 "Cp1255", 77 "Cp1256", 78 "Cp1257", 79 "Cp1258", 80 //"Cp1381", 81 //"Cp1383", 82 //"Cp273", 83 //"Cp277", 84 //"Cp278", 85 //"Cp280", 86 //"Cp284", 87 //"Cp285", 88 //"Cp297", 89 //"Cp33722", 90 //"Cp420", 91 //"Cp424", 92 "Cp437", 93 //"Cp500", 94 //"Cp50220", 95 //"Cp50221", 96 "Cp737", 97 "Cp775", 98 //"Cp834", 99 //"Cp838", 100 "Cp850", 101 "Cp852", 102 "Cp855", 103 "Cp856", 104 "Cp857", 105 "Cp858", 106 "Cp860", 107 "Cp861", 108 "Cp862", 109 "Cp863", 110 "Cp864", 111 "Cp865", 112 "Cp866", 113 "Cp868", 114 "Cp869", 115 //"Cp870", 116 //"Cp871", 117 "Cp874", 118 //"Cp875", 119 //"Cp918", 120 "Cp921", 121 "Cp922", 122 //"Cp930", 123 "Cp933", 124 //"Cp935", 125 //"Cp937", 126 //"Cp939", 127 //"Cp942", 128 //"Cp942C", 129 "Cp943", 130 //"Cp943C", 131 "Cp948", 132 "Cp949", 133 //"Cp949C", 134 "Cp950", 135 "Cp964", 136 //"Cp970", 137 //"EUC-JP", 138 "EUC-KR", 139 "EUC_CN", 140 //"EUC_JP", 141 //"EUC_JP_LINUX", 142 //"EUC_JP_Solaris", 143 "EUC_KR", 144 //"EUC_TW", 145 "GB18030", 146 "GB2312", 147 "GBK", 148 //"IBM-Thai", 149 "IBM00858", 150 //"IBM01140", 151 //"IBM01141", 152 //"IBM01142", 153 //"IBM01143", 154 //"IBM01144", 155 //"IBM01145", 156 //"IBM01146", 157 //"IBM01147", 158 //"IBM01148", 159 //"IBM01149", 160 //"IBM037", 161 //"IBM1026", 162 "IBM1047", 163 //"IBM273", 164 //"IBM277", 165 //"IBM278", 166 //"IBM280", 167 //"IBM284", 168 //"IBM285", 169 //"IBM297", 170 //"IBM420", 171 //"IBM424", 172 "IBM437", 173 //"IBM500", 174 "IBM775", 175 "IBM850", 176 "IBM852", 177 "IBM855", 178 "IBM857", 179 "IBM860", 180 "IBM861", 181 "IBM862", 182 "IBM863", 183 "IBM864", 184 "IBM865", 185 "IBM866", 186 "IBM868", 187 "IBM869", 188 //"IBM870", 189 //"IBM871", 190 //"IBM918", 191 //"ISCII91", 192 //"ISO-2022-CN", 193 "ISO-2022-JP", 194 "ISO-2022-KR", 195 "ISO-8859-1", 196 "ISO-8859-13", 197 "ISO-8859-15", 198 "ISO-8859-2", 199 "ISO-8859-3", 200 "ISO-8859-4", 201 "ISO-8859-5", 202 "ISO-8859-6", 203 "ISO-8859-7", 204 "ISO-8859-8", 205 "ISO-8859-9", 206 //"ISO2022CN", 207 "ISO2022JP", 208 "ISO2022KR", 209 //"ISO2022_CN_CNS", 210 //"ISO2022_CN_GB", 211 "ISO8859_1", 212 "ISO8859_13", 213 "ISO8859_15", 214 "ISO8859_2", 215 "ISO8859_3", 216 "ISO8859_4", 217 "ISO8859_5", 218 "ISO8859_6", 219 "ISO8859_7", 220 "ISO8859_8", 221 "ISO8859_9", 222 //"JISAutoDetect", 223 //"JIS_X0201", 224 //"JIS_X0212-1990", 225 "KOI8-R", 226 "KOI8-U", 227 "KOI8_R", 228 "KOI8_U", 229 "MS874", 230 //"MS932", 231 //"MS936", 232 "MS949", 233 "MS950", 234 //"MS950_HKSCS", 235 "MacArabic", 236 "MacCentralEurope", 237 "MacCroatian", 238 "MacCyrillic", 239 //"MacDingbat", 240 "MacGreek", 241 "MacHebrew", 242 "MacIceland", 243 "MacRoman", 244 "MacRomania", 245 //"MacSymbol", 246 "MacThai", 247 "MacTurkish", 248 "MacUkraine", 249 //"PCK", 250 //"SJIS", 251 //"Shift_JIS", 252 "TIS-620", 253 "TIS620", 254 "US-ASCII", 255 "UTF-16", 256 "UTF-16BE", 257 "UTF-16LE", 258 "UTF-32", 259 "UTF-32BE", 260 "UTF-32LE", 261 "UTF-8", 262 "UTF8", 263 "UTF_32", 264 "UTF_32BE", 265 //"UTF_32BE_BOM", 266 "UTF_32LE", 267 //"UTF_32LE_BOM", 268 "UnicodeBig", 269 "UnicodeBigUnmarked", 270 "UnicodeLittle", 271 "UnicodeLittleUnmarked", 272 "windows-1250", 273 "windows-1251", 274 "windows-1252", 275 "windows-1253", 276 "windows-1254", 277 "windows-1255", 278 "windows-1256", 279 "windows-1257", 280 "windows-1258", 281 //"windows-31j", 282 //"x-Big5_Solaris", 283 //"x-EUC-TW", 284 "x-IBM1006", 285 //"x-IBM1025", 286 "x-IBM1046", 287 "x-IBM1097", 288 "x-IBM1098", 289 //"x-IBM1112", 290 //"x-IBM1122", 291 //"x-IBM1123", 292 "x-IBM1124", 293 //"x-IBM1381", 294 //"x-IBM1383", 295 //"x-IBM33722", 296 "x-IBM737", 297 //"x-IBM834", 298 "x-IBM856", 299 "x-IBM874", 300 //"x-IBM875", 301 "x-IBM921", 302 "x-IBM922", 303 //"x-IBM930", 304 "x-IBM933", 305 //"x-IBM935", 306 //"x-IBM937", 307 //"x-IBM939", 308 //"x-IBM942", 309 //"x-IBM942C", 310 "x-IBM943", 311 //"x-IBM943C", 312 "x-IBM948", 313 "x-IBM949", 314 //"x-IBM949C", 315 "x-IBM950", 316 "x-IBM964", 317 //"x-IBM970", 318 //"x-ISCII91", 319 //"x-ISO2022-CN-CNS", 320 //"x-ISO2022-CN-GB", 321 //"x-JIS0208", 322 //"x-JISAutoDetect", 323 "x-Johab", 324 //"x-MS950-HKSCS", 325 "x-MacArabic", 326 "x-MacCentralEurope", 327 "x-MacCroatian", 328 "x-MacCyrillic", 329 //"x-MacDingbat", 330 "x-MacGreek", 331 "x-MacHebrew", 332 "x-MacIceland", 333 "x-MacRoman", 334 "x-MacRomania", 335 //"x-MacSymbol", 336 "x-MacThai", 337 "x-MacTurkish", 338 "x-MacUkraine", 339 //"x-PCK", 340 "x-UTF-16LE-BOM", 341 //"x-UTF-32BE-BOM", 342 //"x-UTF-32LE-BOM", 343 //"x-euc-jp-linux", 344 //"x-eucJP-Open", 345 "x-iso-8859-11", 346 "x-mswin-936", 347 //"x-windows-50220", 348 //"x-windows-50221", 349 "x-windows-874", 350 "x-windows-949", 351 "x-windows-950", 352 //"x-windows-iso2022jp", 353 }; 354 355 public static void main(final String[] args) { 356 final String string = createString(0x10000); 357 for (String encoding : encodings) { 358 System.out.println("Test encoding: " + encoding); 359 new Test4625418(encoding).test(string); 360 } 361 } 362 363 private static String createString(int length) { 364 StringBuilder sb = new StringBuilder(length); 365 while (0 < length--) 366 sb.append((char) length); 367 368 return sb.toString(); 369 } 370 371 private final String encoding; 372 373 private Test4625418(final String encoding) { 374 this.encoding = encoding; 375 } 376 377 private void test(String string) { 378 try { 379 ByteArrayOutputStream output = new ByteArrayOutputStream(); 380 XMLEncoder encoder = new XMLEncoder(output, this.encoding, true, 0); 381 encoder.setExceptionListener(this); 382 encoder.writeObject(string); 383 encoder.close(); 384 385 InputStream input = new ByteArrayInputStream(output.toByteArray()); 386 XMLDecoder decoder = new XMLDecoder(input); 387 decoder.setExceptionListener(this); 388 Object object = decoder.readObject(); 389 decoder.close(); 390 391 if (!string.equals(object)) { 392 throw new Error(this.encoding + " - can't read properly"); 393 } 394 } 395 catch (IllegalCharsetNameException exception) { 396 throw new Error(this.encoding + " - illegal charset name", exception); 397 } 398 catch (UnsupportedCharsetException exception) { 399 throw new Error(this.encoding + " - unsupported charset", exception); 400 } 401 catch (UnsupportedOperationException exception) { 402 throw new Error(this.encoding + " - unsupported encoder", exception); 403 } 404 } 405 406 public void exceptionThrown(Exception exception) { 407 throw new Error(this.encoding + " - internal", exception); 408 } 409 } |