Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/nio/cs/OLD/MS932_OLD.java
41155 views
1
/*
2
* Copyright (c) 2002, 2012, 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
27
import java.nio.ByteBuffer;
28
import java.nio.CharBuffer;
29
import java.nio.charset.Charset;
30
import java.nio.charset.CharsetDecoder;
31
import java.nio.charset.CharsetEncoder;
32
import java.nio.charset.CoderResult;
33
import sun.nio.cs.HistoricallyNamedCharset;
34
import sun.nio.cs.ext.*;
35
36
public class MS932_OLD extends Charset implements HistoricallyNamedCharset
37
{
38
public MS932_OLD() {
39
super("windows-31j-OLD", null);
40
}
41
42
public String historicalName() {
43
return "MS932";
44
}
45
46
public boolean contains(Charset cs) {
47
return ((cs.name().equals("US-ASCII"))
48
|| (cs instanceof JIS_X_0201_OLD)
49
|| (cs instanceof MS932_OLD));
50
}
51
52
public CharsetDecoder newDecoder() {
53
return new Decoder(this);
54
}
55
56
public CharsetEncoder newEncoder() {
57
return new Encoder(this);
58
}
59
60
private static class Decoder extends MS932DB.Decoder
61
// implements DelegatableDecoder
62
{
63
64
JIS_X_0201_OLD.Decoder jisDec0201;
65
66
private Decoder(Charset cs) {
67
super(cs);
68
jisDec0201 = new JIS_X_0201_OLD.Decoder(cs);
69
}
70
71
protected char decodeSingle(int b) {
72
// If the high bits are all off, it's ASCII == Unicode
73
if ((b & 0xFF80) == 0) {
74
return (char)b;
75
}
76
return jisDec0201.decode(b);
77
}
78
79
// Make some protected methods public for use by JISAutoDetect
80
public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
81
return super.decodeLoop(src, dst);
82
}
83
public void implReset() {
84
super.implReset();
85
}
86
public CoderResult implFlush(CharBuffer out) {
87
return super.implFlush(out);
88
}
89
}
90
91
private static class Encoder extends MS932DB.Encoder {
92
93
private JIS_X_0201_OLD.Encoder jisEnc0201;
94
95
96
private Encoder(Charset cs) {
97
super(cs);
98
jisEnc0201 = new JIS_X_0201_OLD.Encoder(cs);
99
}
100
101
protected int encodeSingle(char inputChar) {
102
103
byte b;
104
// \u0000 - \u007F map straight through
105
if ((inputChar & 0xFF80) == 0) {
106
return ((byte)inputChar);
107
}
108
109
if ((b = jisEnc0201.encode(inputChar)) == 0)
110
return -1;
111
else
112
return b;
113
}
114
}
115
}
116
117