public void write(final int c) throws IOException {
        if (c >= 0XDC00 && c <= 0XDFFF) {
            // Low surrogate
            this.surrogatePair.append((char) c);

            if (this.encoder.canEncode(this.surrogatePair)) {
                this.writer.write(this.surrogatePair.toString());
            } else {
                this.writer.write("&#x");
                this.writer.write(Integer.toHexString(0X10000 + ((this.surrogatePair.charAt(0) & 0X3FF) << 10) + (c & 0X3FF)));
                this.writer.write(';');
            }

            this.haveHighSurrogate = false;
            this.surrogatePair.setLength(0);
        } else {
            if (this.haveHighSurrogate) {
                this.haveHighSurrogate = false;
                this.surrogatePair.setLength(0);
                throw new IOException("High Surrogate not followed by Low Surrogate");
            }

            if (c >= 0XD800 && c <= 0XDBFF) {
                // High surrogate
                this.surrogatePair.append((char) c);
                this.haveHighSurrogate = true;

            } else if (!this.encoder.canEncode((char) c)) {
                this.writer.write("&#x");
                this.writer.write(Integer.toHexString(c));
                this.writer.write(';');
            } else if (c == '\'' && this.writingAttribute && !useDoubleQuotes) {
                this.writer.write("&apos;");
            } else if (c == '"' && this.writingAttribute && useDoubleQuotes) {
                this.writer.write("&quot;");
            } else if (c == '\n' && this.writingAttribute) {
                this.writer.write("&#10;");
            } else if (c == '\r' && this.writingAttribute) {
                this.writer.write("&#13;");
            } else if (c == '\t' && this.writingAttribute) {
                this.writer.write("&#09;");
            } else {
                this.writer.write(c);
            }
        }
    }
public void write ( final int c ) throws IOException { if ( c >= 0XDC00 && c <= 0XDFFF ) { this . surrogatePair . append ( ( char ) c ) ; if ( this . encoder . canEncode ( this . surrogatePair ) ) { this . writer . write ( this . surrogatePair . toString ( ) ) ; } else { this . writer . write ( "&#x" ) ; this . writer . write ( Integer . toHexString ( 0X10000 + ( ( this . surrogatePair . charAt ( 0 ) & 0X3FF ) << 10 ) + ( c & 0X3FF ) ) ) ; this . writer . write ( ';' ) ; } this . haveHighSurrogate = false ; this . surrogatePair . setLength ( 0 ) ; } else { if ( this . haveHighSurrogate ) { this . haveHighSurrogate = false ; this . surrogatePair . setLength ( 0 ) ; throw new IOException ( "High Surrogate not followed by Low Surrogate" ) ; } if ( c >= 0XD800 && c <= 0XDBFF ) { this . surrogatePair . append ( ( char ) c ) ; this . haveHighSurrogate = true ; } else if ( ! this . encoder . canEncode ( ( char ) c ) ) { this . writer . write ( "&#x" ) ; this . writer . write ( Integer . toHexString ( c ) ) ; this . writer . write ( ';' ) ; } else if ( c == '\'' && this . writingAttribute && ! useDoubleQuotes ) { this . writer . write ( "&apos;" ) ; } else if ( c == '"' && this . writingAttribute && useDoubleQuotes ) { this . writer . write ( "&quot;" ) ; } else if ( c == '\n' && this . writingAttribute ) { this . writer . write ( "&#10;" ) ; } else if ( c == '\r' && this . writingAttribute ) { this . writer . write ( "&#13;" ) ; } else if ( c == '\t' && this . writingAttribute ) { this . writer . write ( "&#09;" ) ; } else { this . writer . write ( c ) ; } } }
/* (non-Javadoc)
@see java.io.Writer#write(int)