1 /* |
|
2 * Copyright (c) 2003, 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. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package sun.io; |
|
27 |
|
28 import sun.nio.cs.ext.JIS_X_0208_Solaris_Decoder; |
|
29 |
|
30 /** |
|
31 * |
|
32 * @author Limin Shi |
|
33 * @author Mark Son-Bell |
|
34 * @author Ian Little |
|
35 * |
|
36 * |
|
37 * PCK Converter for Solaris ja locales |
|
38 * refer to : Solaris manpage man PCK(5) |
|
39 * Incorporates mappings from NEC row 13 and IBM select extension chars |
|
40 * in addition to those defined within JIS X0208:1997 (bugID: 4765370) |
|
41 * |
|
42 */ |
|
43 |
|
44 public class ByteToCharPCK extends ByteToCharSJIS { |
|
45 ByteToCharJIS0201 bcJIS0201 = new ByteToCharJIS0201(); |
|
46 ByteToCharJIS0208_Solaris bcJIS0208 = new ByteToCharJIS0208_Solaris(); |
|
47 |
|
48 public String getCharacterEncoding() { |
|
49 return "PCK"; |
|
50 } |
|
51 |
|
52 protected char convSingleByte(int b) { |
|
53 // If the high bits are all off, it's ASCII == Unicode |
|
54 if ((b & 0xFF80) == 0) { |
|
55 return (char)b; |
|
56 } |
|
57 return bcJIS0201.getUnicode(b); |
|
58 } |
|
59 |
|
60 protected char getUnicode(int c1, int c2) { |
|
61 char outChar; |
|
62 if ((outChar = super.getUnicode(c1, c2)) != '\uFFFD') { |
|
63 // Map JIS X 0208:1983 0x213D <--> U+2015 |
|
64 return ((outChar != '\u2014')? outChar: '\u2015'); |
|
65 } else { |
|
66 int adjust = c2 < 0x9F ? 1 : 0; |
|
67 int rowOffset = c1 < 0xA0 ? 0x70 : 0xB0; |
|
68 int cellOffset = (adjust == 1) ? (c2 > 0x7F ? 0x20 : 0x1F) : 0x7E; |
|
69 int b1 = ((c1 - rowOffset) << 1) - adjust; |
|
70 int b2 = c2 - cellOffset; |
|
71 outChar = bcJIS0208.getUnicode(b1, b2); |
|
72 return outChar; |
|
73 } |
|
74 } |
|
75 |
|
76 String prt(int i) { |
|
77 return Integer.toString(i,16); |
|
78 } |
|
79 } |
|