if (isUTF16Surrogate(ch))
if (Encodings.isHighUTF16Surrogate(ch))
    public void writeAttrString(        final java.io.Writer writer, String string, String encoding)        throws IOException    {        final int end = string.length();        if (end > m_attrBuff.length)        {            m_attrBuff = new char[end * 2 + 1];        }        string.getChars(0, end, m_attrBuff, 0);        final char[] chars = m_attrBuff;                int cleanStart = 0;        int cleanLength = 0;        char ch = 0;        for (int i = 0; i < end; i++)        {            ch = chars[i];            // System.out.println("SPECIALSSIZE: "+SPECIALSSIZE);            // System.out.println("ch: "+(int)ch);            // System.out.println("m_maxCharacter: "+(int)m_maxCharacter);            // System.out.println("m_attrCharsMap[ch]: "+(int)m_attrCharsMap[ch]);            if (escapingNotNeeded(ch) && (!m_charInfo.isSpecialAttrChar(ch)))            {                cleanLength++;            }            else if ('<' == ch || '>' == ch)            {                cleanLength++; // no escaping in this case, as specified in 15.2            }            else if (                ('&' == ch) && ((i + 1) < end) && ('{' == chars[i + 1]))            {                cleanLength++; // no escaping in this case, as specified in 15.2            }            else            {                if (cleanLength > 0)                {                    writer.write(chars,cleanStart,cleanLength);                    cleanLength = 0;                }                int pos = accumDefaultEntity(writer, ch, i, chars, end, false, true);                if (i != pos)                {                    i = pos - 1;                }                else                {                    if (isUTF16Surrogate(ch))                    {                             writeUTF16Surrogate(ch, chars, i, end);                            i++; // two input characters processed                                 // this increments by one and the for()                                 // loop itself increments by another one.                    }                    // The next is kind of a hack to keep from escaping in the case                     // of Shift_JIS and the like.                    /*                    else if ((ch < m_maxCharacter) && (m_maxCharacter == 0xFFFF)                    && (ch != 160))                    {                    writer.write(ch);  // no escaping in this case                    }                    else                    */                    String outputStringForChar = m_charInfo.getOutputStringForChar(ch);                    if (null != outputStringForChar)                    {                        writer.write(outputStringForChar);                    }                    else if (escapingNotNeeded(ch))                    {                        writer.write(ch); // no escaping in this case                    }                    else                    {                        writer.write("&#");                        writer.write(Integer.toString(ch));                        writer.write(';');                    }                }                cleanStart = i + 1;            }        } // end of for()                // are there any clean characters at the end of the array        // that we haven't processed yet?        if (cleanLength > 1)        {            // if the whole string can be written out as-is do so            // otherwise write out the clean chars at the end of the            // array            if (cleanStart == 0)                writer.write(string);            else                writer.write(chars, cleanStart, cleanLength);        }        else if (cleanLength == 1)        {            // a little optimization for 1 clean character            // (we could have let the previous if(...) handle them all)            writer.write(ch);        }    }