Here you can find the source of utf8CharLen(byte byte1)
private static int utf8CharLen(byte byte1)
//package com.java2s; /*//from w w w . jav a2 s . c om * Copyright 2014 Bazaarvoice, 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 int utf8CharLen(byte byte1) { if ((byte1 & 0x80) == 0) { return 1; } else if ((byte1 & 0xE0) == 0xC0) { return 2; } else if ((byte1 & 0xF0) == 0xE0) { return 3; } else if ((byte1 & 0xF8) == 0xF0) { return 4; } else if ((byte1 & 0xFC) == 0xF8) { return 5; } else { return 6; } } }