third_party/closure/goog/labs/format/csv.js
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, '"');
  }
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, '"');
  }
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 , '"' ) ; }
Read a quoted field from input.
@return {string} The field, as a string.
Read a quoted field from input .