private void writeEscaped(final char[] buffer, final int offset, final int len) throws IOException {
        

        final int maxi = offset + len;
        for (int i = offset; i < maxi; i++) {
            final char c = buffer[i];
            if (c == '\n') {
                this.writer.write("<br />");
            } else if (c == ' ') {
                this.writer.write("&nbsp;");
            } else if (c == '\t') {
                this.writer.write("&nbsp;&nbsp;&nbsp;&nbsp;");
            } else if (c == '<') {
                this.writer.write("&lt;");
            } else if (c == '>') {
                this.writer.write("&gt;");
            } else if (c == '&') {
                this.writer.write("&amp;");
            } else if (c == '\"') {
                this.writer.write("&quot;");
            } else if (c == '\'') {
                this.writer.write("&#39;");
            } else {
                this.writer.write(c);
            }
        }

    }