Java String Unquote unquote(char[] ca, int pos, StringBuffer out)

Here you can find the source of unquote(char[] ca, int pos, StringBuffer out)

Description

unquote

License

Open Source License

Declaration

public static int unquote(char[] ca, int pos, StringBuffer out) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w  w w  .java  2  s. co  m*/
     *
     */
    public static int unquote(char[] ca, int pos, StringBuffer out) {
        if (ca[pos++] != '"') {
            throw new IllegalArgumentException("Input not a quoted string");
        }
        while (ca[pos] != '"') {
            char c = ca[pos++];
            if (c == '\\') {
                switch (ca[pos++]) {
                case '"':
                    c = '"';
                    break;
                case '\\':
                    c = '\\';
                    break;
                case 'n':
                    c = '\n';
                    break;
                case 'r':
                    c = '\r';
                    break;
                default:
                    throw new IllegalArgumentException("Illegal escape char in quoted string: \\" + ca[pos - 1]);
                }
            }
            if (out != null) {
                out.append(c);
            }
        }
        return pos + 1;
    }
}

Related

  1. unquote(final CharSequence quotePhrase)
  2. unquote(final String aInput)
  3. unquote(final String in)
  4. unQuote(final String quoted)