String str = "任意の文字列"; for (int i = 0; i < str.length(); i++) { if (UnicodeBlock.of(str.codePointAt(i)) == UnicodeBlock.LOW_SURROGATES) { // 処理しない } else { // 何らかの処理 } }
String.codePointCount() で得られた文字数分だけ String.codePointAt() でぐるぐる回せばいいもんだと思い込んでいた。
String.codePointCount() は単に実際の文字数が何文字あるかをカウントするだけで、文字列に対して処理をするには上記のようにやる必要がある。