/*
Write text to the output

(non-Javadoc)

@see javax.xml.stream.XMLStreamWriter#writeCharacters(java.lang.String)
15707
public void writeCharacters(String text) throws XMLStreamException {
		try {
			this.checkPendingATEvents();
			encoder.encodeCharacters(new StringValue(text));
		} catch (Exception e) {
			throw new XMLStreamException(e.getLocalizedMessage(), e);
		}
	}
1160575
public function write($chars)
    {
        if (!isset($this->charReader)) {
            $this->charReader = $this->charReaderFactory->getReaderFor(
                $this->charset);
            $this->map = [];
            $this->mapType = $this->charReader->getMapType();
        }
        $ignored = '';
        $this->datas .= $chars;
        $this->charCount += $this->charReader->getCharPositions(substr($this->datas, $this->datasSize), $this->datasSize, $this->map, $ignored);
        if (false !== $ignored) {
            $this->datasSize = strlen($this->datas) - strlen($ignored);
        } else {
            $this->datasSize = strlen($this->datas);
        }
    }
1251122
public static void putCharacterList(Writer writer, List<Character> values) throws IOException {
		if (values == null) {
			writer.write("null");
		} else {
			startArray(writer);
			for (int i = 0; i < values.size(); i++) {
				put(writer, values.get(i));
				if (i != values.size() - 1) {
					addSeparator(writer);
				}
			}
			endArray(writer);
		}
	}
1065049
private void flushCharacters() throws org.xml.sax.SAXException
  {

    XSLTElementProcessor elemProcessor = getCurrentProcessor();

    if (null != elemProcessor)
      elemProcessor.startNonText(this);
  }
160121
public static void write(File file, String text, String charset) throws IOException {
        write(file, text, charset, false);
    }
1209829
public void write(XMLStreamWriter writer, String xmlElementName) throws XMLStreamException {
      if (isModified()) {
         writer.writeStartElement(xmlElementName);
         write(writer);
         writer.writeEndElement();
      }
   }
858382
@Override
	public void write(final String string, final int off, final int len) {
		for (int i = off; i < off + len; i++) {
			write(string.charAt(i));
		}
	}
529048
@Override
    public void write(String str) {
		int len = str.length();
		for (int i = 0; i < len; i++) {
			append(str.charAt(i));
		}
    }
193947
private static void writeParagraphs(final String text, final XmlStringBuilder xml) {
		if (!Util.empty(text)) {
			int start = 0;
			int end = text.length() - 1;

			// Set the start index to the first non-linebreak, so we don't emit leading ui:nl tags
			for (; start < end; start++) {
				char c = text.charAt(start);

				if (c != '\n' && c != '\r') {
					break;
				}
			}

			// Set the end index to the last non-linebreak, so we don't emit trailing ui:nl tags
			for (; start < end; end--) {
				char c = text.charAt(end);

				if (c != '\n' && c != '\r') {
					break;
				}
			}

			char lastChar = 0;

			for (int i = start; i <= end; i++) {
				char c = text.charAt(i);

				if (c == '\n' || c == '\r') {
					if (lastChar != 0) {
						xml.write("<ui:nl/>");
					}

					lastChar = 0;
				} else {
					xml.write(c);
					lastChar = c;
				}
			}
		}
	}
36086
public void write(int c) {
        if (c != -1) {
            current.append((char)c);
        }
        if (c == '\n') {
            current = new StringBuilder();
            lines.add(current);
        }
    }
614162
public static void write(OutputStream out, Charset charset, boolean isCloseOut, Object... contents) throws IORuntimeException {
		OutputStreamWriter osw = null;
		try {
			osw = getWriter(out, charset);
			for (Object content : contents) {
				if (content != null) {
					osw.write(Convert.toStr(content, StrUtil.EMPTY));
					osw.flush();
				}
			}
		} catch (IOException e) {
			throw new IORuntimeException(e);
		} finally {
			if (isCloseOut) {
				close(osw);
			}
		}
	}
44897
public static String writeCharacter(Character value) {
		if (value==null) return null;
		
		return Integer.toString((int)value);			
	}
651536
@Override
    public void setCharacterEncoding(String charset) {
        if (null != this.outWriter || isCommitted()) {
            return;
        }
        if (null != charset) {
            this.encoding = connection.getEncodingUtils().stripQuotes(charset);
        }
        if (null != this.contentType) {
            int index = this.contentType.indexOf("charset=");
            StringBuilder sb = new StringBuilder();
            if (-1 != index) {
                sb.append(this.contentType.substring(0, index - 1).trim());
            } else {
                sb.append(this.contentType);
            }
            if (this.encoding != null) {
                sb.append(";charset=").append(this.encoding);
            }

            this.contentType = sb.toString();
            this.response.setHeader("Content-Type", this.contentType);
        }
    }
445402
public static void writeString(String s, DataOutputStream out) throws IOException
    {
        out.writeInt(s.length());
        for (char c : s.toCharArray())
        {
            out.writeChar(c);
        }
    }
1352546
private void processCharacters(final Characters paramText) throws IOException, XMLStreamException,
        TTException {
        assert paramText != null;
        // Initialize variables.
        initializeVars();
        final String text = paramText.getData().toString();
        if (!text.isEmpty()) {
            // Main algorithm to determine if same, insert or a delete has to be
            // made.
            algorithm(paramText);

            if (mFound && mIsRightSibling) {
                /*
                 * Cannot happen because if text node after end tag get's
                 * deleted it's done already while parsing the end tag. If text
                 * node should be deleted at the top of a subtree (right after a
                 * start tag has been parsed) it's done in
                 * processStartTag(StartElement).
                 */
                // mDelete = EDelete.ATSTARTMIDDLE;
                // deleteNode();
                throw new AssertionError("");
            } else if (!mFound) {
                insertTextNode(paramText);
            } else if (mFound) {
                sameTextNode();
            }
        }
    }
122122
public void write(char ... data) throws IllegalStateException, IOException{
        write(StandardCharsets.US_ASCII, CharBuffer.wrap(data));
    }
103225
public static void writeStringAsText(DataOutput stream, String str) throws IOException {
    byte[] utf8Encoded = str.getBytes(StandardCharsets.UTF_8);
    writeVLong(stream, utf8Encoded.length);
    stream.write(utf8Encoded);
  }