public static int codePointAsUtf8Length(int codepoint) {
        if (codepoint < 0x800) {
            if (codepoint < 0x80) {
                return 1;
            } else {
                return 2;
            }
        } else {
            if (codepoint < 0x10000) {
                return 3;
            } else {
                return 4;
            }
        }
    }
Return the number of octets needed to encode a valid Unicode codepoint as UTF-8.

@param codepoint the Unicode codepoint to inspect
@return the number of bytes needed for UTF-8 representation
vespajlib/src/main/java/com/yahoo/text/Utf8.java