public Utf8String substring(int utf8CharBeginIndex, int utf8CharEndIndex) {
        if (utf8CharBeginIndex < 0) {
            throw new IndexOutOfBoundsException(
                    "The begin index must be greater than or equal to 0");
        }
        if (utf8CharEndIndex > charCount) {
            throw new IndexOutOfBoundsException(
                    "The end index must be less than "
                            + charCount);
        }
        if (utf8CharBeginIndex > utf8CharEndIndex) {
            throw new IndexOutOfBoundsException(
                    "The begin index must be less than or equal to the end index");
        }
        int beginFirstByteIndex = byteOffset;
        int endByteIndex = byteOffset + byteCount;
        int seenCharacters = 0;
        byte[] localBytes = bytes;
        byte firstByte;
        while (seenCharacters < utf8CharBeginIndex && beginFirstByteIndex < endByteIndex) {
            firstByte = localBytes[beginFirstByteIndex];
            int count = getByteCountFromFirstUtf8Byte(firstByte);
            if (count > 0) {
                beginFirstByteIndex += count;
                seenCharacters++;
            }
        }

        int endFirstByteIndex = beginFirstByteIndex;
        while (seenCharacters < utf8CharEndIndex && endFirstByteIndex < endByteIndex) {
            firstByte = localBytes[endFirstByteIndex];
            int count = getByteCountFromFirstUtf8Byte(firstByte);
            if (count > 0) {
                endFirstByteIndex += count;
                seenCharacters++;
            }
        }

        int newByteCount = endFirstByteIndex - beginFirstByteIndex;
        String newStr =
                new String(localBytes, beginFirstByteIndex, newByteCount, StandardCharsets.UTF_8);
        return new Utf8String(
                newStr,
                localBytes,
                beginFirstByteIndex,
                newByteCount,
                utf8CharEndIndex - utf8CharBeginIndex);
    }
@see java.nio.charset.CharsetEncoder#maxBytesPerChar()
turms-server-common/src/main/java/im/turms/server/common/infra/lang/Utf8String.java