array.append(new StringValueImpl(sb.toString()));
array.append(sb);
  public Value fgetcsv(Env env,                       @NotNull StreamResource file,                       @Optional int length,                       @Optional String delimiter,                       @Optional String enclosure)  {    // php/1619    try {      if (file == null)	return BooleanValue.FALSE;      // XXX: length is never used      if (length <= 0)	length = Integer.MAX_VALUE;      int comma = ',';      if (delimiter != null && delimiter.length() > 0)	comma = delimiter.charAt(0);      int quote = '"';      if (enclosure != null && enclosure.length() > 0)	quote = enclosure.charAt(0);      ArrayValue array = new ArrayValueImpl();      int ch;      while (true) {	// scan whitespace	while (true) {	  ch = file.read();	  if (ch < 0 || ch == '\n')	    return array;	  else if (ch == '\r') {	    file.readOptionalLinefeed();	    return array;	  }	  else if (ch == ' ' || ch == '\t')	    continue;	  else	    break;	}	StringBuilder sb = new StringBuilder();	if (ch == quote) {	  for (ch = file.read(); ch >= 0; ch = file.read()) {	    if (ch == quote) {	      ch = file.read();	      if (ch == quote)		sb.append((char) ch);	      else		break;	    }	    else	      sb.append((char) ch);	  }	  array.append(new StringValueImpl(sb.toString()));	  for (; ch >= 0 && ch == ' ' || ch == '\t'; ch = file.read()) {	  }	}	else {	  for (;	       ch >= 0 && ch != comma && ch != '\r' && ch != '\n';	       ch = file.read()) {	    sb.append((char) ch);	  }	  array.append(new StringValueImpl(sb.toString()));	}	if (ch < 0)	  return array;	else if (ch == '\n')	  return array;	else if (ch == '\r') {	  file.readOptionalLinefeed();	  return array;	}	else if (ch == comma) {	}	else {	  env.warning("expected comma");	}      }    } catch (IOException e) {      throw new QuercusModuleException(e);    }  }