Writes a character to the output stream with the correct encoding.

@param ch the character to write.
328196
@Override
  public void write(ByteAppendable os, char ch)
    throws IOException
  {
    if (ch < 0x80) {
      os.write(ch);
    }
    else if (ch < 0x800) {
      os.write((0xc0 + (ch >> 6)));
      os.write((0x80 + (ch & 0x3f)));
    }
    else {
      os.write((0xe0 + (ch >> 12)));
      os.write((0x80 + ((ch >> 6) & 0x3f)));
      os.write((0x80 + (ch & 0x3f)));
    }
  }
428189
function gli_put_char(str, ch) {
    if (!str || !str.writable)
        throw('gli_put_char: invalid stream');

    if (!str.unicode) {
        if (ch < 0 || ch >= 0x100)
            ch = 63;  // '?'
    }

    str.writecount += 1;
    
    switch (str.type) {
    case strtype_File:
        if (str.streaming) {
            if (!str.unicode) {
                str.buffer4[0] = ch;
                str.fstream.fwrite(str.buffer4, 1);
            }
            else {
                if (!str.isbinary) {
                    /* cheap UTF-8 stream */
                    var len;
                    if (ch < 0x10000) {
                        len = str.buffer4.write(String.fromCharCode(ch));
                        str.fstream.fwrite(str.buffer4, len); // utf8
                    }
                    else {
                        /* String.fromCharCode chokes on astral characters;
                           do it the hard way */
                        var arr8 = UniArrayToUTF8([ch]);
                        var buf = new str.fstream.BufferClass(arr8);
                        str.fstream.fwrite(buf);
                    }
                }
                else {
                    /* cheap big-endian stream */
                    str.buffer4.writeUInt32BE(ch, 0, true);
                    str.fstream.fwrite(str.buffer4, 4);
                }
            }
        }
        else {
            /* non-streaming... */
            gli_stream_dirty_file(str);
            if (!str.unicode || (ch < 0x80 && !str.isbinary)) {
                if (str.bufpos < str.buflen) {
                    str.buf[str.bufpos] = ch;
                    str.bufpos += 1;
                    if (str.bufpos > str.bufeof)
                        str.bufeof = str.bufpos;
                }
            }
            else {
                var arr;
                if (!str.isbinary)
                    arr = UniArrayToUTF8([ch]);
                else
                    arr = UniArrayToBE32([ch]);
                var len = arr.length;
                if (len > str.buflen-str.bufpos)
                    len = str.buflen-str.bufpos;
                for (ix=0; ix<len; ix++)
                    str.buf[str.bufpos+ix] = arr[ix];
                str.bufpos += len;
                if (str.bufpos > str.bufeof)
                    str.bufeof = str.bufpos;
            }
        }
        break;
    case strtype_Memory:
        if (str.bufpos < str.buflen) {
            str.buf[str.bufpos] = ch;
            str.bufpos += 1;
            if (str.bufpos > str.bufeof)
                str.bufeof = str.bufpos;
        }
        break;
    case strtype_Window:
        if (str.win.line_request)
            throw('gli_put_char: window has pending line request');
        gli_window_put_string(str.win, CharToString(ch));
        if (str.win.echostr)
            gli_put_char(str.win.echostr, ch);
        break;
    }
}
474720
public void characters(char ch[], int start, int length)
			throws SAXException {
		String arg0 = new String(ch);
		arg0 = arg0.substring(start, start + length);
//		System.out.println(arg0);

		if (arg0.startsWith("\n"))
			return;

		this.processValue(arg0);
	}
1133445
protected static final String printable(char ch) {
		StringBuffer retval = new StringBuffer();
		addPrintable(retval, ch);
		return retval.toString();
	}
1333133
public void printJavaChar(char ch) throws IOException
  {
    switch (ch) {
    case '\\':
      _os.print("\\\\");
      break;
    case '\n':
      _os.print("\\n");
      break;
    case '\r':
      _os.print("\\r");
      break;
    case '\'':
      _os.print("\\'");
      break;
    default:
      _os.print(ch);
    }
  }
1301035
private void _appendCharacterEscape(char ch, int escCode)
			throws IOException, JsonGenerationException
	{
		if (escCode >= 0) { // \\N (2 char)
			if ((_outputTail + 2) > _outputEnd) {
				_flushBuffer();
			}
			_outputBuffer[_outputTail++] = '\\';
			_outputBuffer[_outputTail++] = (char) escCode;
			return;
		}
		if (escCode != CharacterEscapes.ESCAPE_CUSTOM) { // std, \\uXXXX
			if ((_outputTail + 5) >= _outputEnd) {
				_flushBuffer();
			}
			int ptr = _outputTail;
			char[] buf = _outputBuffer;
			buf[ptr++] = '\\';
			buf[ptr++] = 'u';
			// We know it's a control char, so only the last 2 chars are non-0
			if (ch > 0xFF) { // beyond 8 bytes
				int hi = (ch >> 8) & 0xFF;
				buf[ptr++] = HEX_CHARS[hi >> 4];
				buf[ptr++] = HEX_CHARS[hi & 0xF];
				ch &= 0xFF;
			} else {
				buf[ptr++] = '0';
				buf[ptr++] = '0';
			}
			buf[ptr++] = HEX_CHARS[ch >> 4];
			buf[ptr++] = HEX_CHARS[ch & 0xF];
			_outputTail = ptr;
			return;
		}
		String escape;
		if (_currentEscape == null) {
			escape = _characterEscapes.getEscapeSequence(ch).getValue();
		} else {
			escape = _currentEscape.getValue();
			_currentEscape = null;
		}
		int len = escape.length();
		if ((_outputTail + len) > _outputEnd) {
			_flushBuffer();
			if (len > _outputEnd) { // very very long escape; unlikely but theoretically possible
				_writer.write(escape);
				return;
			}
		}
		escape.getChars(0, len, _outputBuffer, _outputTail);
		_outputTail += len;
	}
377510
public static final void write(WritableByteChannel ch, byte[] bytes, int offset, int length) throws IOException
    {
        ByteBuffer bb = ByteBuffer.allocate(length);
        bb.put(bytes, offset, length);
        bb.flip();
        writeAll(ch, bb);
    }
829916
public void writeToWriter(Writer out) throws IOException
  {
    int ch;

    while ((ch = readChar()) >= 0) {
      out.write((char) ch);
    }
  }
1228085
@Override
    public Writer append(char c) throws IOException {
        singleCharBuffer[0]=(char)c;
        encodedAppender.append(encoder, null, singleCharBuffer, 0, 1);
        return this;
    }
382395
final protected void putChar(char c) {
        final int clen = _internalBuffer.length;
        if (clen == _bufferPosition) {
            final char[] next = new char[2 * clen + 1];

            System.arraycopy(_internalBuffer, 0, next, 0, _bufferPosition);
            _internalBuffer = next;
        }

        _internalBuffer[_bufferPosition++] = c;
    }
607116
public static final void write(WritableByteChannel ch, String text, Charset charset) throws IOException
    {
        write(ch, text.getBytes(charset));
    }
780864
@Override
    public void characters(char[] ch, int start, int length)
            throws SAXException {
        try {
            for (int j = 0; j < length; j++) {
                char c = ch[start + j];
                switch (c) {
                    case '<':
                        this.writer.write("&lt;");
                        break;
                    case '>':
                        this.writer.write("&gt;");
                        break;
                    case '&':
                        this.writer.write("&amp;");
                        break;
                    default:
                        this.writer.write(c);
                }
            }
        } catch (IOException ioe) {
            throw (SAXException)new SAXException(ioe).initCause(ioe);
        }
    }
525358
public void append(char c) {
        if (this.length + 1 > this.ch.length) {
                    int newLength = this.ch.length*2;
                    if (newLength < this.ch.length + DEFAULT_SIZE)
                        newLength = this.ch.length + DEFAULT_SIZE;
                    char[] newch = new char[newLength];
                    System.arraycopy(this.ch, 0, newch, 0, this.length);
                    this.ch = newch;
        }
        this.ch[this.length] = c;
        this.length++;
    }
595364
private void writeSimpleString(OutputStream out, CharSequence value) throws IOException {
        out.write('"');
        for (int i = 0; i < value.length(); i++) {
            out.write(value.charAt(i));
        }
        out.write('"');
    }
176542
private void writeChar(final char chr) throws IOException {
    switch (chr) {
      case '\t':
        this.Tab();
        break;
      case '\n': {
        this.out.write(this.lineSeparator);
        this.lineNumber++;
        this.prevMode = this.mode;
        this.mode = MODE_START_LINE;
        this.linePosition = 0;
        for (final Extra e : extras) {
          e.onNewLine(this, this.lineNumber);
        }
      }
      break;
      case '\r':
        break;
      default: {
        if (!Character.isISOControl(chr)) {
          this.out.write(chr);
          this.linePosition++;
          if (this.mode == MODE_START_LINE) {
            this.mode = this.prevMode;
          }
        }
      }
      break;
    }
  }
1299890
public void write(int c) throws IOException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
        { // 306998.15
            Tr.debug(tc, "write --> " + c);
        }

        if (!_hasWritten && obs != null)
        {
            _hasWritten = true;
            obs.alertFirstWrite();
        }

        if (limit > -1)
        {
            if (total >= limit)
            {
                throw new WriteBeyondContentLengthException();
            }
        }
        if (count == buf.length)
        {
            response.setFlushMode(false);
            flushChars();
            response.setFlushMode(true);
        }
        buf[count++] = (char) c;
        total++;
    }
875323
@Override
  public void write (final int c) throws IOException
  {
    _ensureOpen ();
    if (m_nNextChar >= m_nChars)
      flushBuffer ();
    m_aBuf[m_nNextChar++] = (char) c;
  }