MoreStringUtil { public static int utf8EncodedLength(@Nullable CharSequence sequence) { if (StringUtils.isEmpty(sequence)) { return 0; } return Utf8.encodedLength(sequence); }  static List<String> split(@Nullable final String str, final char separatorChar); static List<String> split(@Nullable final String str, final char separatorChar, int expectParts); static Splitter charsSplitter(final String separatorChars); static String replaceFirst(@Nullable String s, char sub, char with); static String replaceLast(@Nullable String s, char sub, char with); static boolean startWith(@Nullable CharSequence s, char c); static boolean endWith(@Nullable CharSequence s, char c); static String removeEnd(final String s, final char c); static int utf8EncodedLength(@Nullable CharSequence sequence);  }
@Test public void utf8EncodedLength() { assertThat(MoreStringUtil.utf8EncodedLength("ab12")).isEqualTo(4); assertThat(MoreStringUtil.utf8EncodedLength("中文")).isEqualTo(6); }