Read a quoted string.
It is an error if the beginning of the next tag is detected.
18356
@SuppressWarnings("fallthrough")
    protected void quotedString() {
        int pos = bp;
        nextChar();

        loop:
        while (bp < buflen) {
            switch (ch) {
                case '\n': case '\r': case '\f':
                    newline = true;
                    break;

                case ' ': case '\t':
                    break;

                case '"':
                    nextChar();
                    // trim trailing white-space?
                    return;

                case '@':
                    if (newline)
                        break loop;

            }
            nextChar();
        }
    }
1176280
@SuppressWarnings("fallthrough")
    protected DCText quotedString() {
        int pos = bp;
        nextChar();

        loop:
        while (bp < buflen) {
            switch (ch) {
                case '\n': case '\r': case '\f':
                    newline = true;
                    break;

                case ' ': case '\t':
                    break;

                case '"':
                    nextChar();
                    // trim trailing white-space?
                    return m.at(pos).newTextTree(newString(pos, bp));

                case '@':
                    if (newline)
                        break loop;

            }
            nextChar();
        }
        return null;
    }
1101398
function (quote) {
      var str;
      var n = this.html.indexOf(quote, this.currentChar);
      if (n === -1) {
        this.currentChar = this.html.length;
        str = null;
      } else {
        str = this.html.substring(this.currentChar, n);
        this.currentChar = n + 1;
      }

      return str;
    }
581442
function readQuotedField() {
    // We've already consumed the first quote by the time we get here.
    var start = index;
    var end = null;

    for (var token = nextToken(); token != EOF; token = nextToken()) {
      if (token == '"') {
        end = index - 1;
        token = nextToken();

        // Two double quotes in a row.  Keep scanning.
        if (token == '"') {
          end = null;
          continue;
        }

        // End of field.  Break out.
        if (token == delimiter || token == EOF || token == NEWLINE) {
          if (token == NEWLINE) {
            pushBack(token);
          }
          break;
        }

        if (!opt_ignoreErrors) {
          // Ignoring errors here means keep going in current field after
          // closing quote. E.g. "ab"c,d splits into abc,d
          throw new goog.labs.format.csv.ParseError(
              text, index - 1,
              'Unexpected character "' + token + '" after quote mark');
        } else {
          // Fall back to reading the rest of this field as unquoted.
          // Note: the rest is guaranteed not start with ", as that case is
          // eliminated above.
          var prefix = '"' + text.substring(start, index);
          var suffix = readField();
          if (suffix == EOR) {
            pushBack(NEWLINE);
            return prefix;
          } else {
            return prefix + suffix;
          }
        }
      }
    }

    if (goog.isNull(end)) {
      if (!opt_ignoreErrors) {
        throw new goog.labs.format.csv.ParseError(
            text, text.length - 1, 'Unexpected end of text after open quote');
      } else {
        end = text.length;
      }
    }

    // Take substring, combine double quotes.
    return text.substring(start, end).replace(/""/g, '"');
  }
442975
private String quotedAV() {
    pos++;
    beg = pos;
    end = beg;
    while (true) {

      if (pos == length) {
        throw new IllegalStateException("Unexpected end of DN: " + dn);
      }

      if (chars[pos] == '"') {
        // enclosing quotation was found
        pos++;
        break;
      } else if (chars[pos] == '\\') {
        chars[end] = getEscaped();
      } else {
        // shift char: required for string with escaped chars
        chars[end] = chars[pos];
      }
      pos++;
      end++;
    }

    // skip trailing space chars before comma or semicolon.
    // (compatibility with RFC 1779)
    for (; pos < length && chars[pos] == ' '; pos++) {
    }

    return new String(chars, beg, end - beg);
  }
725674
function getQuoted (string) {
  if (!string.match(/"/g)) {
    return '"' + string + '"'
  }
  stringify = requireOnce('json-stringify-safe')
  return stringify(String(string))
}
1126772
def parse_string(data, unquote=default_unquote):
    
    if data is None:
        return None

    # We'll soon need to unquote to recover our UTF-8 data.
    # In Python 2, unquote crashes on chars beyond ASCII. So encode functions
    # had better not include anything beyond ASCII in data.
    # In Python 3, unquote crashes on bytes objects, requiring conversion to
    # str objects (unicode) using decode().
    # But in Python 2, the same decode causes unquote to butcher the data.
    # So in that case, just leave the bytes.
    if isinstance(data, bytes):
        if sys.version_info > (3, 0, 0):  # pragma: no cover
            data = data.decode('ascii')
    # Recover URL encoded data
    unquoted = unquote(data)
    # Without this step, Python 2 may have good URL decoded *bytes*,
    # which will therefore not normalize as unicode and not compare to
    # the original.
    if isinstance(unquoted, bytes):
        unquoted = unquoted.decode('utf-8')
    return unquoted
822835
def l_sa_check(template, literal, is_standalone):
    """"""

    # If there is a newline, or the previous tag was a standalone
    if literal.find('\n') != -1 or is_standalone:
        padding = literal.split('\n')[-1]

        # If all the characters since the last newline are spaces
        if padding.isspace() or padding == '':
            # Then the next tag could be a standalone
            return True
        else:
            # Otherwise it can't be
            return False
348051
def _tag_extent(self, data, start):
        
        in_quote = False
        quotable = False
        lto = len(self.tag_opener)
        ltc = len(self.tag_closer)
        for i in xrange(start + 1, len(data)):
            ch = data[i]
            if ch == '=':
                quotable = True
            if ch in ('"', "'"):
                if quotable and not in_quote:
                    in_quote = ch
                elif in_quote == ch:
                    in_quote = False
                    quotable = False
            if not in_quote and data[i:i + lto] == self.tag_opener:
                return i, False
            if not in_quote and data[i:i + ltc] == self.tag_closer:
                return i + ltc, True
        return len(data), False
1187214
private void readQuote( char quote, StringBuilder builder ) {
        builder.append( quote );
        boolean isBackslash = false;
        for( ;; ) {
            char ch = read();
            builder.append( ch );
            if( ch == quote && !isBackslash ) {
                return;
            }
            isBackslash = ch == '\\';
        }
    }
818567
def parse_quoted_string(header: str, pos: int, header_name: str) -> Tuple[str, int]:
    
    match = _quoted_string_re.match(header, pos)
    if match is None:
        raise InvalidHeaderFormat(header_name, "expected quoted string", header, pos)
    return _unquote_re.sub(r"\1", match.group()[1:-1]), match.end()
294063
private StringBuilder appendQuotedString(final String pattern, final ParsePosition pos,
            final StringBuilder appendTo) {
        assert pattern.toCharArray()[pos.getIndex()] == QUOTE :
            "Quoted string must start with quote character";

        // handle quote character at the beginning of the string
        if(appendTo != null) {
            appendTo.append(QUOTE);
        }
        next(pos);

        final int start = pos.getIndex();
        final char[] c = pattern.toCharArray();
        final int lastHold = start;
        for (int i = pos.getIndex(); i < pattern.length(); i++) {
            switch (c[pos.getIndex()]) {
            case QUOTE:
                next(pos);
                return appendTo == null ? null : appendTo.append(c, lastHold,
                        pos.getIndex() - lastHold);
            default:
                next(pos);
            }
        }
        throw new IllegalArgumentException(
                "Unterminated quoted string at position " + start);
    }
1167785
def parse_str(io, stop_quote)
      buf = ''
      loop do
        c = io.read_one_char
        if c.nil?
          raise Error, "The IO ran out before the end of a literal string"
        elsif buf.length > 0 && buf[-1..-1] == ESC # If this char was escaped
          # Trim the escape character at the end of the buffer
          buf = buf[0..-2] 
          buf << c
        elsif c == stop_quote
          return buf
        else
          buf << c
        end
      end
    end
1123018
private String[] parseLine(String nextLine, boolean multi) throws IOException {

        if (!multi && pending != null) {
            pending = null;
        }

        if (nextLine == null) {
            if (pending != null) {
                String s = pending;
                pending = null;
                return new String[]{s};
            } else {
                return null;
            }
        }

        List<String> tokensOnThisLine = new ArrayList<String>();
        StringBuilder sb = new StringBuilder(INITIAL_READ_SIZE);
        boolean inQuotes = false;
        if (pending != null) {
            sb.append(pending);
            pending = null;
            inQuotes = true;
        }
        for (int i = 0; i < nextLine.length(); i++) {

            char c = nextLine.charAt(i);
            if (c == this.escape) {
                if (isNextCharacterEscapable(nextLine, inQuotes || inField, i)) {
                    sb.append(nextLine.charAt(i + 1));
                    i++;
                }
            } else if (c == quotechar) {
                if (isNextCharacterEscapedQuote(nextLine, inQuotes || inField, i)) {
                    sb.append(nextLine.charAt(i + 1));
                    i++;
                } else {
                    //inQuotes = !inQuotes;

                    // the tricky case of an embedded quote in the middle: a,bc"d"ef,g
                    if (!strictQuotes) {
                        if (i > 2 //not on the beginning of the line
                                && nextLine.charAt(i - 1) != this.separator //not at the beginning of an escape sequence
                                && nextLine.length() > (i + 1) &&
                                nextLine.charAt(i + 1) != this.separator //not at the	end of an escape sequence
                                ) {

                            if (ignoreLeadingWhiteSpace && sb.length() > 0 && isAllWhiteSpace(sb)) {
                                sb.setLength(0);  //discard white space leading up to quote
                            } else {
                                sb.append(c);
                                //continue;
                            }

                        }
                    }

                    inQuotes = !inQuotes;
                }
                inField = !inField;
            } else if (c == separator && !inQuotes) {
                tokensOnThisLine.add(sb.toString());
                sb.setLength(0); // start work on next token
                inField = false;
            } else {
                if (!strictQuotes || inQuotes) {
                    sb.append(c);
                    inField = true;
                }
            }
        }
        // line is done - check status
        if (inQuotes) {
            if (multi) {
                // continuing a quoted section, re-append newline
                sb.append("\n");
                pending = sb.toString();
                sb = null; // this partial content is not to be added to field list yet
            } else {
                throw new IOException("Un-terminated quoted field at end of CSV line");
            }
        }
        if (sb != null) {
            tokensOnThisLine.add(sb.toString());
        }
        return tokensOnThisLine.toArray(new String[tokensOnThisLine.size()]);

    }
69682
function isQuotedString(str) {
  var is = false;
  if(typeof str === 'string') {
    var firstChar = str.charAt(0);
    is = (['"', "'", '`'].indexOf(firstChar) !== -1);
  }
  return is;
}
641887
private static int quoteSingle(final StringBuilder sb, final String string, final int start) {
        int i = start+1;
        if (needsBlockQuoting(string.charAt(start))) return -i;
        int unquoteLen = 0;
        int quotedMap = 1;
        for (int j = 1; i < string.length(); i++, j++) {
            char c = string.charAt(i);
            if (needsQuoting(c)) {
                if (j > MAX_SINGLE_QUOTE_LEN || needsBlockQuoting(c)) return -i-1;
                quotedMap |= 1 << j;
                unquoteLen = 0;
            } else {
                if (unquoteLen == MAX_UNQUOTE_LEN ||
                        (quotedMap == 1 && 
                         unquoteLen == MAX_SINGLE_UNQUOTE_LEN)) {
                    break;
                }
                unquoteLen++;
            }
        }
        appendSingleQuoted(sb, string, start, i - unquoteLen, quotedMap);
        sb.append(string, i - unquoteLen, i);
        return i;
    }
845362
static void unescapeBraceFormat(StringBuilder out, String message, int start, int end) {
    int pos = start;
    boolean isQuoted = false;
    while (pos < end) {
      char c = message.charAt(pos++);
      // We catch single quotes and escaped single quotes.
      if (c != '\\' && c != '\'') {
        continue;
      }
      int quoteStart = pos - 1;
      if (c == '\\') {
        // Shouldn't risk index out of bounds here because that would be a trailing single '\'.
        c = message.charAt(pos++);
        if (c != '\'') {
          continue;
        }
      }
      // Always skip the first single-quote we find.
      out.append(message, start, quoteStart);
      start = pos;
      if (pos == end) {
        break;
      }
      if (isQuoted) {
        isQuoted = false;
      } else if (message.charAt(pos) != '\'') {
        isQuoted = true;
      } else {
        // If there are two adjacent single-quotes, advance our position so we don't detect it
        // when we go back to the top of the loop (this does mean reading that same char twice
        // if it wasn't a single quote, but this is relatively rare).
        pos++;
      }
    }
    // Append the last section (if it's non empty).
    if (start < end) {
      out.append(message, start, end);
    }
  }