/** * Un-escape a text string as escaped using {@link #escapeText(String)}. * Two-digit hex escapes (starting with "\x") are also recognized. */ static String unescapeText(String input) throws InvalidEscapeSequence { return new UTF8Buffer(unescapeBytes(input)).toString(); }
/** * Un-escape a text string as escaped using {@link #escapeText(String)}. * Two-digit hex escapes (starting with "\x") are also recognized. */ static String unescapeText(String input) throws InvalidEscapeSequence { return new UTF8Buffer(unescapeBytes(input)).toString(); }
/** * Un-escape a text string as escaped using {@link #escapeText(String)}. * Two-digit hex escapes (starting with "\x") are also recognized. */ static String unescapeText(String input) throws InvalidEscapeSequence { return new UTF8Buffer(unescapeBytes(input)).toString(); }
/** * If the next token is a string, consume it, unescape it as a * {@link Buffer}, and return it. Otherwise, throw a * {@link ParseException}. */ public Buffer consumeBuffer() throws ParseException { char quote = currentToken.length() > 0 ? currentToken.charAt(0) : '\0'; if (quote != '\"' && quote != '\'') { throw parseException("Expected string."); } if (currentToken.length() < 2 || currentToken.charAt(currentToken.length() - 1) != quote) { throw parseException("String missing ending quote."); } try { String escaped = currentToken.substring(1, currentToken.length() - 1); Buffer result = unescapeBytes(escaped); nextToken(); return result; } catch (InvalidEscapeSequence e) { throw parseException(e.getMessage()); } }
/** * If the next token is a string, consume it, unescape it as a * {@link Buffer}, and return it. Otherwise, throw a * {@link ParseException}. */ public Buffer consumeBuffer() throws ParseException { char quote = currentToken.length() > 0 ? currentToken.charAt(0) : '\0'; if (quote != '\"' && quote != '\'') { throw parseException("Expected string."); } if (currentToken.length() < 2 || currentToken.charAt(currentToken.length() - 1) != quote) { throw parseException("String missing ending quote."); } try { String escaped = currentToken.substring(1, currentToken.length() - 1); Buffer result = unescapeBytes(escaped); nextToken(); return result; } catch (InvalidEscapeSequence e) { throw parseException(e.getMessage()); } }
/** * If the next token is a string, consume it, unescape it as a * {@link Buffer}, and return it. Otherwise, throw a * {@link ParseException}. */ public Buffer consumeBuffer() throws ParseException { char quote = currentToken.length() > 0 ? currentToken.charAt(0) : '\0'; if (quote != '\"' && quote != '\'') { throw parseException("Expected string."); } if (currentToken.length() < 2 || currentToken.charAt(currentToken.length() - 1) != quote) { throw parseException("String missing ending quote."); } try { String escaped = currentToken.substring(1, currentToken.length() - 1); Buffer result = unescapeBytes(escaped); nextToken(); return result; } catch (InvalidEscapeSequence e) { throw parseException(e.getMessage()); } }