/*
* 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.
*/
/**
* UCS2 (UTF16) -> UCS Transformation Format 8 (UTF-8) converter
* It's represented like below.
*
* # Bits Bit pattern
* 1 7 0xxxxxxx
* 2 11 110xxxxx 10xxxxxx
* 3 16 1110xxxx 10xxxxxx 10xxxxxx
* 4 21 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
* 5 26 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
* 6 31 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
*
* UCS2 uses 1-3 / UTF16 uses 1-4 / UCS4 uses 1-6
*/
private char highHalfZoneCode;
throws MalformedInputException
{
if (highHalfZoneCode != 0) {
highHalfZoneCode = 0;
badInputLength = 0;
throw new MalformedInputException();
}
return 0;
}
/**
* Character conversion
*/
{
char inputChar;
byte[] outputByte = new byte[6];
int inputSize;
int outputSize;
if (highHalfZoneCode != 0) {
highHalfZoneCode = 0;
// This is legal UTF16 sequence.
charOff++;
highHalfZoneCode = 0;
} else {
// This is illegal UTF16 sequence.
badInputLength = 0;
throw new MalformedInputException();
}
}
if (inputChar < 0x80) {
inputSize = 1;
outputSize = 1;
} else if (inputChar < 0x800) {
inputSize = 1;
outputSize = 2;
// this is <high-half zone code> in UTF-16
break;
}
// check next char is valid <low-half zone code>
badInputLength = 1;
throw new MalformedInputException();
}
+ 0x10000;
outputSize = 4;
inputSize = 2;
} else {
inputSize = 1;
outputSize = 3;
}
throw new ConversionBufferFullException();
}
for (int i = 0; i < outputSize; i++) {
}
}
}
return true;
}
public int getMaxBytesPerChar() {
return 3;
}
public void reset() {
highHalfZoneCode = 0;
}
return "UTF8";
}
}