public static IntsRef toUTF32(char[] s, int offset, int length, IntsRefBuilder scratch) {int charIdx = offset;int intIdx = 0;final int charLimit = offset + length;while(charIdx < charLimit) {scratch.grow(intIdx+1);final int utf32 = Character.codePointAt(s, charIdx, charLimit);scratch.setIntAt(intIdx, utf32);charIdx += Character.charCount(utf32);intIdx++;}scratch.setLength(intIdx);return scratch.get();}
public static Int32sRef ToUTF32(char[] s, int offset, int length, Int32sRef scratch){int charIdx = offset;int intIdx = 0;int charLimit = offset + length;while (charIdx < charLimit){scratch.Grow(intIdx + 1);int utf32 = Character.CodePointAt(s, charIdx, charLimit);scratch.Int32s[intIdx] = utf32;charIdx += Character.CharCount(utf32);intIdx++;}scratch.Length = intIdx;return scratch;}