text: public static int codePointCount(BytesRef utf8) {int pos = utf8.offset;final int limit = pos + utf8.length;final byte[] bytes = utf8.bytes;int codePointCount = 0;for (; pos < limit; codePointCount++) {int v = bytes[pos] & 0xFF;if (v <    0x80) { pos += 1; continue; }if (v >=   0xc0) {if (v <  0xe0) { pos += 2; continue; }if (v <  0xf0) { pos += 3; continue; }if (v <  0xf8) { pos += 4; continue; }}throw new IllegalArgumentException();}if (pos > limit) throw new IllegalArgumentException();return codePointCount;}