StringBuilder bld = new StringBuilder(gramSize);
for (int i = 0; i < len; i++) {
bld.setLength(0);
int offset = pos;
for (int count = 0; count < gramSize && offset < text.length(); count++) {
<BUG>int codepoint = text.codePointAt(offset);
</BUG>
offset += Character.charCount(codepoint);
if (count == 0)
pos = offset;   // advance pos to next character

StringBuilder bld = new StringBuilder(gramSize);
for (int i = 0; i < len; i++) {
bld.setLength(0);
int offset = pos;
for (int count = 0; count < gramSize && offset < text.length(); count++) {
int codepoint = Character.toLowerCase(text.codePointAt(offset));
offset += Character.charCount(codepoint);
if (count == 0)
pos = offset;   // advance pos to next character
