Java UTF8 Convert To utf8ToCodePoint(int b1, int b2, int b3, int b4)

Here you can find the source of utf8ToCodePoint(int b1, int b2, int b3, int b4)

Description

utf To Code Point

License

Apache License

Declaration

private static int utf8ToCodePoint(int b1, int b2, int b3, int b4) 

Method Source Code

//package com.java2s;
/*//from  w  w w.  j  a  v  a 2s  . c o m
 *  * Copyright 2016 Skymind, Inc.
 *  *
 *  *    Licensed under the Apache License, Version 2.0 (the "License");
 *  *    you may not use this file except in compliance with the License.
 *  *    You may obtain a copy of the License at
 *  *
 *  *        http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  *    Unless required by applicable law or agreed to in writing, software
 *  *    distributed under the License is distributed on an "AS IS" BASIS,
 *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  *    See the License for the specific language governing permissions and
 *  *    limitations under the License.
 */

public class Main {
    private static final int B11 = Integer.parseInt("11000000", 2);
    private static final int B111 = Integer.parseInt("11100000", 2);
    private static final int B1111 = Integer.parseInt("11110000", 2);
    private static final int B11111 = Integer.parseInt("11111000", 2);

    private static int utf8ToCodePoint(int b1, int b2, int b3, int b4) {
        int cpt;
        cpt = (((b1 & ~B11111) << 18) | ((b2 & ~B11) << 12) | ((b3 & ~B11) << 6) | (b4 & ~B11));
        return cpt;
    }

    private static int utf8ToCodePoint(int b1, int b2, int b3) {
        int cpt = 0;
        cpt = (((b1 & ~B1111) << 12) | ((b2 & ~B11) << 6) | (b3 & ~B11));
        return cpt;
    }

    private static int utf8ToCodePoint(int b1, int b2) {
        int cpt = 0;
        cpt = (((b1 & ~B111) << 6) | (b2 & ~B11));
        return cpt;
    }
}

Related

  1. getBytesUtf8(String string)
  2. getBytesUtf8(String string)
  3. getBytesUTF8(String string)
  4. getBytesUtf8(String string)
  5. UTF8ToCodePoint(byte[] b, int s)
  6. utf8Togb2312(String str)
  7. utf8ToString(byte[] src, int stPos, int utf8Len)
  8. utf8ToUnicode(String inStr)
  9. utfToChars(byte[] src, int srcIndex, char[] dst, int dstIndex, int len)