Here you can find the source of utf8ToCodePoint(int b1, int b2, int b3, int b4)
private static int utf8ToCodePoint(int b1, int b2, int b3, int b4)
//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; } }