if (!(0xdc00 <= next && next < 0xe000))
if (!(Encodings.isLowUTF16Surrogate(next)))
    protected int accumDefaultEscape(        Writer writer,        char ch,        int i,        char[] chars,        int len,        boolean fromTextNode,        boolean escLF)        throws IOException    {        int pos = accumDefaultEntity(writer, ch, i, chars, len, fromTextNode, escLF);        if (i == pos)        {            if (0xd800 <= ch && ch < 0xdc00)            {                // UTF-16 surrogate                int next;                if (i + 1 >= len)                {                    throw new IOException(                        Utils.messages.createMessage(                            MsgKey.ER_INVALID_UTF16_SURROGATE,                            new Object[] { Integer.toHexString(ch)}));                    //"Invalid UTF-16 surrogate detected: "                    //+Integer.toHexString(ch)+ " ?");                }                else                {                    next = chars[++i];                    if (!(0xdc00 <= next && next < 0xe000))                        throw new IOException(                            Utils.messages.createMessage(                                MsgKey                                    .ER_INVALID_UTF16_SURROGATE,                                new Object[] {                                    Integer.toHexString(ch)                                        + " "                                        + Integer.toHexString(next)}));                    //"Invalid UTF-16 surrogate detected: "                    //+Integer.toHexString(ch)+" "+Integer.toHexString(next));                    next = ((ch - 0xd800) << 10) + next - 0xdc00 + 0x00010000;                }                writer.write("&#");                writer.write(Integer.toString(next));                writer.write(';');                pos += 2; // count the two characters that went into writing out this entity            }            else            {                /*  This if check is added to support control characters in XML 1.1.                 *  If a character is a Control Character within C0 and C1 range, it is desirable                 *  to write it out as Numeric Character Reference(NCR) regardless of XML Version                 *  being used for output document.                 */                 if (isCharacterInC0orC1Range(ch) ||                         (XMLVERSION11.equals(getVersion()) && isNELorLSEPCharacter(ch)))                {                    writer.write("&#");                    writer.write(Integer.toString(ch));                    writer.write(';');                }                else if ((!escapingNotNeeded(ch) ||                     (  (fromTextNode && m_charInfo.isSpecialTextChar(ch))                     || (!fromTextNode && m_charInfo.isSpecialAttrChar(ch))))                 && m_elemContext.m_currentElemDepth > 0)                {                    writer.write("&#");                    writer.write(Integer.toString(ch));                    writer.write(';');                }                else                {                    writer.write(ch);                }                pos++;  // count the single character that was processed            }        }        return pos;    }