1 /* |
1 /* |
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
1019 } |
1019 } |
1020 return ent.getData(); |
1020 return ent.getData(); |
1021 } |
1021 } |
1022 |
1022 |
1023 /** |
1023 /** |
1024 * Converts numeric character reference to Unicode character. |
1024 * Converts numeric character reference to char array. |
1025 * |
1025 * |
1026 * Normally the code in a reference should be always converted |
1026 * Normally the code in a reference should be always converted |
1027 * to the Unicode character with the same code, but due to |
1027 * to the Unicode character with the same code, but due to |
1028 * wide usage of Cp1252 charset most browsers map numeric references |
1028 * wide usage of Cp1252 charset most browsers map numeric references |
1029 * in the range 130-159 (which are control chars in Unicode set) |
1029 * in the range 130-159 (which are control chars in Unicode set) |
1030 * to displayable characters with other codes. |
1030 * to displayable characters with other codes. |
1031 * |
1031 * |
1032 * @param c the code of numeric character reference. |
1032 * @param c the code of numeric character reference. |
1033 * @return the character corresponding to the reference code. |
1033 * @return a char array corresponding to the reference code. |
1034 */ |
1034 */ |
1035 private char mapNumericReference(char c) { |
1035 private char[] mapNumericReference(int c) { |
1036 if (c < 130 || c > 159) { |
1036 char[] data; |
1037 return c; |
1037 if (c >= 0xffff) { // outside unicode BMP. |
1038 } |
1038 try { |
1039 return cp1252Map[c - 130]; |
1039 data = Character.toChars(c); |
|
1040 } catch (IllegalArgumentException e) { |
|
1041 data = new char[0]; |
|
1042 } |
|
1043 } else { |
|
1044 data = new char[1]; |
|
1045 data[0] = (c < 130 || c > 159) ? (char) c : cp1252Map[c - 130]; |
|
1046 } |
|
1047 return data; |
1040 } |
1048 } |
1041 |
1049 |
1042 /** |
1050 /** |
1043 * Parse a comment. [92] 391:7 |
1051 * Parse a comment. [92] 391:7 |
1044 */ |
1052 */ |