// Note: Since Java 8 we can just stream code points as integers. This was for Java 7. public static int[] convertUTF16ToUTF32(final String utf16) { final int length = utf16.length(); final int[] utf32 = new int[utf16.codePointCount(0, length)]; int index = 0; int offset = 0; int codepoint; while (offset < length) { codepoint = utf16.codePointAt(offset); utf32[index++] = codepoint; offset += Character.charCount(codepoint); } assert index == utf32.length; return utf32; }