Java Utililty Methods UTF8 Convert To

List of utility methods to do UTF8 Convert To

Description

The list of methods to do UTF8 Convert To are organized into topic(s).

Method

byte[]getBytesUtf8(String string)
get Bytes Utf
if (string == null) {
    return null;
return string.getBytes("UTF-8");
intUTF8ToCodePoint(byte[] b, int s)
UTF To Code Point
if (b[s] >> 7 == 0) {
    return b[s];
} else if ((b[s] & 0xe0) == 0xc0) { 
    return (b[s] & 0x1f) << 6 | 
            (b[s + 1] & 0x3f);
} else if ((b[s] & 0xf0) == 0xe0) {
    return (b[s] & 0xf) << 12 | (b[s + 1] & 0x3f) << 6 | (b[s + 2] & 0x3f);
} else if ((b[s] & 0xf8) == 0xf0) {
...
intutf8ToCodePoint(int b1, int b2, int b3, int b4)
utf To Code Point
int cpt;
cpt = (((b1 & ~B11111) << 18) | ((b2 & ~B11) << 12) | ((b3 & ~B11) << 6) | (b4 & ~B11));
return cpt;
Stringutf8Togb2312(String str)
utf Togb
StringBuffer sb = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
    char c = str.charAt(i);
    switch (c) {
    case '+':
        sb.append(' ');
        break;
    case '%':
...
Stringutf8ToString(byte[] src, int stPos, int utf8Len)
utf To String
char[] strBuf = new char[utf8Len];
int i = stPos;
int j = 0;
int limit = stPos + utf8Len;
while (i < limit) {
    int b = src[i++] & 255;
    if (b >= 224) {
        b = (b & 15) << 12;
...
Stringutf8ToUnicode(String inStr)
utf To Unicode
char[] myBuffer = inStr.toCharArray();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < inStr.length(); i++) {
    Character.UnicodeBlock ub = Character.UnicodeBlock.of(myBuffer[i]);
    if (ub == Character.UnicodeBlock.BASIC_LATIN) {
        sb.append(myBuffer[i]);
    } else if (ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
        int j = (int) myBuffer[i] - 65248;
...
intutfToChars(byte[] src, int srcIndex, char[] dst, int dstIndex, int len)
Convert `len' bytes from utf8 to characters.
int i = srcIndex;
int j = dstIndex;
int limit = srcIndex + len;
while (i < limit) {
    int b = src[i++] & 0xFF;
    if (b >= 0xE0) {
        b = (b & 0x0F) << 12;
        b = b | (src[i++] & 0x3F) << 6;
...