/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
{
/*
(1) EUC_TW
Second byte of EUC_TW for cs2 is in range of
0xA1-0xB0 for plane 1-16. According to CJKV /163,
plane1 is coded in both cs1 and cs2. This impl
however does not decode the codepoints of plane1
in cs2, so only p2-p7 and p15 are supported in cs2.
Plane2 0xA2;
Plane3 0xA3;
Plane4 0xA4;
Plane5 0xA5;
Plane6 0xA6;
Plane7 0xA7;
Plane15 0xAF;
(2) Mapping
The fact that all supplementary characters encoded in EUC_TW are
in 0x2xxxx range gives us the room to optimize the data tables.
Decoding:
(1) save the lower 16-bit value of all codepoints of b->c mapping
in a String array table String[plane] b2c.
(2) save "codepoint is supplementary" info (one bit) in a
byte[] b2cIsSupp, so 8 codepoints (same codepoint value, different
plane No) share one byte.
Encoding:
(1)c->b mappings are stored in
(2)byte[] c2bPlane stores the "plane info" of each euc-tw codepoints,
Mapping tables are stored separated in EUC_TWMapping, which
is generated by tool.
*/
public EUC_TW() {
}
return "EUC_TW";
}
}
return new Decoder(this);
}
return new Encoder(this);
}
}
}
static final byte[] b2cIsSupp;
// adjust from cns planeNo to the plane index of b2c
static {
}
//static final BitSet b2cIsSupp;
static {
// work on a local copy is much faster than operate
// directly on b2cIsSupp
int off = 0;
char c = b2cIsSuppStr.charAt(i);
}
}
static boolean isLegalDB(int b) {
}
{
return null;
if (c == UNMAPPABLE_DECODING)
return null;
c1[0] = c;
return c1;
} else {
return c2;
}
}
{
try {
return CoderResult.UNDERFLOW;
if (cnsPlane < 0)
}
return CoderResult.OVERFLOW;
} else {
}
sp += 4;
return CoderResult.OVERFLOW;
sp++;
} else { // Codeset 1 G1
return CoderResult.UNDERFLOW;
}
return CoderResult.OVERFLOW;
sp += 2;
}
}
return CoderResult.UNDERFLOW;
} finally {
}
}
{
try {
while (src.hasRemaining()) {
return CoderResult.UNDERFLOW;
if (cnsPlane < 0)
}
return CoderResult.OVERFLOW;
} else {
}
mark += 4;
if (!dst.hasRemaining())
return CoderResult.OVERFLOW;
mark++;
} else { // Codeset 1 G1
if (!src.hasRemaining())
return CoderResult.UNDERFLOW;
}
if (!dst.hasRemaining())
return CoderResult.OVERFLOW;
mark +=2;
}
}
return CoderResult.UNDERFLOW;
} finally {
}
}
{
else
}
}
}
public boolean canEncode(char c) {
}
int i = 0;
if (Character.isHighSurrogate(c)) {
return false;
return false;
} else if (!canEncode(c)) {
return false;
}
}
return true;
}
}
}
{
int inSize;
int outSize;
try {
inSize = 1;
if (c < 0x80) { // ASCII
bb[0] = (byte)c;
outSize = 1;
} else {
if (outSize == -1) {
// to check surrogates only after BMP failed
// has the benefit of improving the BMP encoding
// 10% faster, with the price of the slowdown of
// supplementary character encoding. given the use
// of supplementary characters is really rare, this
// is something worth doing.
if (Character.isHighSurrogate(c)) {
return CoderResult.UNDERFLOW;
inSize = 2;
} else if (Character.isLowSurrogate(c)) {
}
}
}
if (outSize == -1)
return CoderResult.OVERFLOW;
for (int i = 0; i < outSize; i++)
}
return CoderResult.UNDERFLOW;
} finally {
}
}
{
int outSize;
int inSize;
try {
while (src.hasRemaining()) {
inSize = 1;
if (c < 0x80) { // ASCII
outSize = 1;
bb[0] = (byte)c;
} else {
if (outSize == -1) {
if (Character.isHighSurrogate(c)) {
if (!src.hasRemaining())
return CoderResult.UNDERFLOW;
inSize = 2;
} else if (Character.isLowSurrogate(c)) {
}
}
}
if (outSize == -1)
return CoderResult.OVERFLOW;
for (int i = 0; i < outSize; i++)
}
return CoderResult.UNDERFLOW;
} finally {
}
}
{
else
}
if ((c & 0xf0000) != 0x20000)
return -1;
c -= 0x20000;
if (index == UNMAPPABLE_ENCODING)
return -1;
if (db == UNMAPPABLE_ENCODING)
return -1;
return 4;
}
if (index == UNMAPPABLE_ENCODING)
return -1;
if (db == UNMAPPABLE_ENCODING)
return -1;
if (p == 0) {
return 2;
} else {
return 4;
}
}
static final char[] c2b;
static final char[] c2bIndex;
static final char[] c2bSupp;
static final char[] c2bSuppIndex;
static final byte[] c2bPlane;
static {
/*
adjust the "plane" from 0..7 to 0, 2, 3, 4, 5, 6, 7, 0xf,
which helps balance between footprint (to save the plane
info in 4 bits) and runtime performance (to require only
one operation "0xa0 | plane" to encode the plane byte)
*/
int plane = p;
if (plane == 7)
plane = 0xf;
else if (plane != 0)
plane = p + 1;
int off = 0;
if (c != UNMAPPABLE_DECODING) {
} else {
}
}
off++;
}
}
}
}
}
}