Here you can find the source of bytesUTF8len(byte[] buf, int bufOffset, int bufLength)
Parameter | Description |
---|---|
buf | a parameter |
private static int bytesUTF8len(byte[] buf, int bufOffset, int bufLength)
//package com.java2s; public class Main { /**/*from w ww . j a va2 s . c o m*/ * get the length of the bytes in UTF-8 * rules: 0xxxxxxx or 11xxxxxx is the first the byte of the * @param buf * @return */ private static int bytesUTF8len(byte[] buf, int bufOffset, int bufLength) { int len = 0; for (int i = bufOffset; i < (bufOffset + bufLength); i++) { if (((buf[i]) & 0x80) == 0x00 || ((buf[i]) & 0xc0) == 0xc0) { len++; } } return len; } }