else if ((buffer.getLength()) < length)
{
buffer.ensureSize(length);
}
final CodePointStream cps = new CodePointStream(buffer, 10);
final int maxPos = offset + length;
for (int i = offset; i < maxPos; i++)
{
final char c = chars[i];
if ((c & 0xFC00) == 0xD800)
{
i += 1;
if (i < maxPos)
{
final char c2 = chars[i];
if ((c2 & 0xFC00) == 0xDC00)
{
final int codePoint = 0x10000 +
((c2 & 0x3FF) | ((c & 0x3FF) << 10));
cps.put(codePoint);
}
else
{
// Should not happen ..
}
}
else
{
// illegal char .. ignore it ..
// of course: This should not happen, as this produced by JDK code
break;
}
}
else
{
cps.put(c);
}
}
cps.close();
return buffer;
}