Java String Unquote unquote(String toUnquote, char quoteChar)

Here you can find the source of unquote(String toUnquote, char quoteChar)

Description

Unquote special characters.

License

Open Source License

Parameter

Parameter Description
toUnquote The String which may contain quoted special characters.
quoteChar The quoting character.

Return

A String with all quoted characters unquoted.

Declaration

public static String unquote(String toUnquote, char quoteChar) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*  w ww.  ja v a2s .  c o m*/
     * Unquote special characters.
     *
     * @param toUnquote         The String which may contain quoted special characters.
     * @param quoteChar The quoting character.
     * @return A String with all quoted characters unquoted.
     */
    public static String unquote(String toUnquote, char quoteChar) {
        StringBuilder result = new StringBuilder();
        char c;
        boolean quoted = false;
        for (int i = 0; i < toUnquote.length(); ++i) {
            c = toUnquote.charAt(i);
            if (quoted) { // append literally...
                if (c != '\n') {
                    result.append(c);
                }
                quoted = false;
            } else if (c == quoteChar) {
                // quote char
                quoted = true;
            } else {
                result.append(c);
            }
        }
        return result.toString();
    }
}

Related

  1. unquote(String string)
  2. unquote(String string, char quote)
  3. unquote(String text)
  4. unquote(String text)
  5. unquote(String text)
  6. unquote(String val)
  7. unquote(String val)
  8. unquote(String value)
  9. unquote(String value)