/*
(non-Javadoc)
@see org.xml.sax.ContentHandler#characters(char[], int, int)
330126
public void characters(char ch[], int start, int length) throws SAXException
   {
      try
      {
         importer.characters(ch, start, length);
      }
      catch (RepositoryException e)
      {
         throw new SAXException(e);
      }

   }
1280031
public char[] readChars (int length) throws KryoException {
		char[] array = new char[length];
		if (optional(length << 1) == length << 1) {
			byte[] buffer = this.buffer;
			int p = this.position;
			for (int i = 0; i < length; i++, p += 2)
				array[i] = (char)((buffer[p] & 0xFF) | ((buffer[p + 1] & 0xFF)) << 8);
			position = p;
		} else {
			for (int i = 0; i < length; i++)
				array[i] = readChar();
		}
		return array;
	}
755062
public static String[] chars(final String value) {
        validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        return value.split("");
    }
644644
@Override
	public void characters(char[] text, int start, int length) throws SAXException
	{
		if (length > 0)
		{
			String data = String.valueOf(text, start, length).replace('\n', ' ').replace('\t', ' ').trim();
			if (data.length() > 0)
			{
				Command.prn(tabCount, tabCount + ">setting data=" + data //$NON-NLS-1$
						+ "<EOL>"); //$NON-NLS-1$
				Command cmd = stack.peek();
				cmd.setData(data);
			}
		}
	}
1104979
public char[] getCharacters() {
        if (c.length == length) {
            return c;
        }
        char[] chars = new char[length];
        System.arraycopy(c, 0, chars, 0, length);
        return chars;
    }
693993
public static String encodeXML( final String    str )
    {
        if ( str == null )
        {
            return null;
        }

        StringCharacterIterator    iterator = new StringCharacterIterator( str );
        StringBuilder              result   = new StringBuilder();
        char                       c;

        for( c  = iterator.current();
             c != CharacterIterator.DONE;
             c  = iterator.next() )
        {
            if ( c == '>' )
            {
                result.append( "&gt;" );
            }
            else if ( c == '<' )
            {
                result.append( "&lt;" );
            }
            else if ( c == '&' )
            {
                result.append( "&amp;" );
            }
            else if ( c == '"' )
            {
                result.append( "&quot;" );
            }
            else if ( c == '\'' )
            {
                result.append( "&#39;" );
            }
            else
            {
                result.append( c );
            }
        }

        return result.toString();
    }
408454
@Override
    public void characters(char[] ch, int start, int length) throws SAXException {

        // <param-name>
        if (elements("web-app", "context-param", "param-name")) {
            currentName = String.valueOf(ch, start, length).trim();
        }

        // <param-value>
        if (elements("web-app", "context-param", "param-value")) {
            currentValue = String.valueOf(ch, start, length).trim();
        }

    }
170044
public char charAt( int idx )
    {
        if ( idx < 0 )
            throw new IndexOutOfBoundsException("idx{"+idx+"} < 0");
        if ( idx >= count )
            throw new IndexOutOfBoundsException("idx{"+idx+"} >= buffer.length");
        return buff[idx];
    }
1043238
private void parseCharRef(boolean doFlush) throws SAXException, IOException {
        int value = 0;
        char c;

        if (tryRead('x')) {
            loop1: while (true) {
                c = readCh();
                if (c == ';') {
                    break loop1;
                } else {
                    int n = Character.digit(c, 16);
                    if (n == -1) {
                        fatal("illegal character in character reference", c,
                                null);
                        break loop1;
                    }
                    value *= 16;
                    value += n;
                }
            }
        } else {
            loop2: while (true) {
                c = readCh();
                if (c == ';') {
                    break loop2;
                } else {
                    int n = Character.digit(c, 10);
                    if (n == -1) {
                        fatal("illegal character in character reference", c,
                                null);
                        break loop2;
                    }
                    value *= 10;
                    value += c - '0';
                }
            }
        }

        // check for character refs being legal XML
        if (((value < 0x0020) && !((value == '\n') || (value == '\t') || (value == '\r')))
                || ((value >= 0xD800) && (value <= 0xDFFF))
                || (value == 0xFFFE)
                || (value == 0xFFFF) || (value > 0x0010ffff)) {
            fatal("illegal XML character reference U+"
                    + Integer.toHexString(value));
        } else if ((value >= 0x007F) && (value <= 0x009F)) // 2006-11-13 hsivonen
        {
            handler.warn("Character reference expands to a control character: U+00"
                    + Integer.toHexString(value) + ".");
        }
        if (isPrivateUse(value)) {
            warnAboutPrivateUseChar();
        }

        // Check for surrogates: 00000000 0000xxxx yyyyyyyy zzzzzzzz
        // (1101|10xx|xxyy|yyyy + 1101|11yy|zzzz|zzzz:
        if (value <= 0x0000ffff) {
            // no surrogates needed
            dataBufferAppend((char) value);
        } else if (value <= 0x0010ffff) {
            value -= 0x10000;
            // > 16 bits, surrogate needed
            dataBufferAppend((char) (0xd800 | (value >> 10)));
            dataBufferAppend((char) (0xdc00 | (value & 0x0003ff)));
        } else {
            // too big for surrogate
            fatal("character reference " + value + " is too large for UTF-16",
                    Integer.valueOf(value).toString(), null);
        }
        if (doFlush) {
            dataBufferFlush();
        }
    }
670507
public static void normalization(char[] charArray)
    {
        assert charArray != null;
        for (int i = 0; i < charArray.length; i++)
        {
            charArray[i] = CONVERT[charArray[i]];
        }
    }
246457
public void characters(org.w3c.dom.Node node)
        throws org.xml.sax.SAXException
    {
        flushPending();
        String data = node.getNodeValue();
        if (data != null)
        {
            final int length = data.length();
            if (length > m_charsBuff.length)
            {
                m_charsBuff = new char[length * 2 + 1];
            }
            data.getChars(0, length, m_charsBuff, 0);
            characters(m_charsBuff, 0, length);
        }
    }
824435
public static String escapeXML(final char[] chars, final int offset, final int length) {
        final StringBuilder escaped = new StringBuilder();

        final int end = offset + length;
        for (int i = offset; i < end; ++i) {
            final char c = chars[i];

            switch (c) {
            case '\'':
                escaped.append("&apos;");
                break;
            case '\"':
                escaped.append("&quot;");
                break;
            case '<':
                escaped.append("&lt;");
                break;
            case '>':
                escaped.append("&gt;");
                break;
            case '&':
                escaped.append("&amp;");
                break;
            default:
                escaped.append(c);
            }
        }

        return escaped.toString();
    }
1098215
private void outputString(String s) throws SAXException {
        handler.characters(s.toCharArray(), 0, s.length());
    }
79393
public static void checkCharacter(char c) throws IOException {
		if(
			(c < 0x20 || c > 0xD7FF) // common case first
			&& c != 0x9
			&& c != 0xA
			&& c != 0xD
			&& (c < 0xE000 || c > 0xFFFD)
			// high and low surrogates
			//&& (c < 0x10000 || c > 0x10FFFF)
			&& (c < Character.MIN_HIGH_SURROGATE || c > Character.MAX_LOW_SURROGATE)

		) throw new IOException(ApplicationResources.accessor.getMessage("XhtmlValidator.invalidCharacter", Integer.toHexString(c)));
	}
1369415
public void characters(final char[] ch, final int start, final int length) throws SAXException {
        charBuffer.append(ch, start, length);
    }
1232586
public void writeCharacters(final String text) throws SAXException {
        if (elementStack.isEmpty()) {
            throw new IllegalStateException("Current state does not allow Character writing");
        }
        final char[] ch = text.toCharArray();
        writeCharacters(ch, 0, ch.length);
    }
825624
public static StringBuilder encodeHtml(StringBuilder buffer, CharSequence chars) {
		chars.chars().forEach(c -> {
			switch (c) {
			case '<':
				buffer.append("&lt;");
				break;
			case '>':
				buffer.append("&gt;");
				break;
			case '&':
				buffer.append("&amp;");
				break;
			case '"':
				buffer.append("&quot;");
				break;
			case '\'':
				buffer.append("&#39;");
				break;
			default:
				if (Character.isAlphabetic(c)) {
					buffer.append((char) c);
				} else {
					buffer.append("&#").append(c).append(';');
				}
			}
		});
		return buffer;
	}