3 Commits
0.3.0 ... 0.3.2

Author SHA1 Message Date
zynode
ae00f949f0 parseCSV 0.3.2
This is primarily a bug-fix release for a critical
bug which was brought to my attention.

- Fixed a critical bug in conditions parsing which
  would generate corrupt matching patterns causing
  the condition(s) to not work at all in some
  situations.

- Fixed a small code error which would cause PHP to
  generate a invalid offset notice when zero length
  values were fed into the unparse() method to
  generate CSV data from an array.

git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@22 339761fc-0c37-0410-822d-8b8cac1f6a97
2008-03-31 22:50:36 +00:00
zynode
4e76da5eff minor fix to a bug which caused notice errors to be generated when _enclose_value() was fed a zero character long string
git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@20 339761fc-0c37-0410-822d-8b8cac1f6a97
2008-03-31 20:55:33 +00:00
zynode
7762e71316 parseCSV 0.3.1
- Small change to default output settings to
  conform with RFC 4180 (http://rfc.net/rfc4180.html).
  Only the LF (line feed) character was used
  by default to separate rows, rather than
  CRLF (carriage return & line feed).

git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@17 339761fc-0c37-0410-822d-8b8cac1f6a97
2007-08-31 22:45:22 +00:00
3 changed files with 59 additions and 11 deletions

View File

@@ -1,3 +1,42 @@
parseCSV 0.3.2
-----------------------------------
Date: 1-Apr-2008
This is primarily a bug-fix release for a critical
bug which was brought to my attention.
- Fixed a critical bug in conditions parsing which
would generate corrupt matching patterns causing
the condition(s) to not work at all in some
situations.
- Fixed a small code error which would cause PHP to
generate a invalid offset notice when zero length
values were fed into the unparse() method to
generate CSV data from an array.
Notice: If you have been using the "parsecsv-stable"
branch as an external in any of your projects,
please use the "stable/parsecsv" branch from this
point on as I will eventually remove the former due
to it's stupid naming.
-----------------------------------
parseCSV 0.3.1
-----------------------------------
Date: 1-Sep-2007
- Small change to default output settings to
conform with RFC 4180 (http://rfc.net/rfc4180.html).
Only the LF (line feed) character was used
by default to separate rows, rather than
CRLF (carriage return & line feed).
-----------------------------------
parseCSV 0.3.0 parseCSV 0.3.0
----------------------------------- -----------------------------------
Date: 9-Aug-2007 Date: 9-Aug-2007
@@ -18,6 +57,9 @@ Date: 9-Aug-2007
- Minor changes and optimizations, and a few - Minor changes and optimizations, and a few
spelling corrections. Oops :) spelling corrections. Oops :)
- Included more complex code examples in the
parseCSV download.
----------------------------------- -----------------------------------

View File

@@ -13,7 +13,11 @@ $csv = new parseCSV();
# Parse '_books.csv' using automatic delimiter detection... # Parse '_books.csv' using automatic delimiter detection...
$csv->auto('_books.csv'); $csv->auto('_books.csv');
# ...or if you know the delimiter, use the parse() function. # ...or if you know the delimiter, set the delimiter character
# if its not the default comma...
// $csv->delimiter = "\t"; # tab delimited
# ...and then use the parse() function.
// $csv->parse('_books.csv'); // $csv->parse('_books.csv');

View File

@@ -4,7 +4,7 @@ class parseCSV {
/* /*
Class: parseCSV v0.3.0 Class: parseCSV v0.3.2
http://code.google.com/p/parsecsv-for-php/ http://code.google.com/p/parsecsv-for-php/
@@ -123,7 +123,7 @@ class parseCSV {
var $output_encoding = 'ISO-8859-1'; var $output_encoding = 'ISO-8859-1';
# used by unparse(), save(), and output() functions # used by unparse(), save(), and output() functions
var $linefeed = "\n"; var $linefeed = "\r\n";
# only used by output() function # only used by output() function
var $output_delimiter = ','; var $output_delimiter = ',';
@@ -601,12 +601,14 @@ class parseCSV {
* @return Processed value * @return Processed value
*/ */
function _enclose_value ($value = null) { function _enclose_value ($value = null) {
if ( $value !== null && $value != '' ) {
$delimiter = preg_quote($this->delimiter, '/'); $delimiter = preg_quote($this->delimiter, '/');
$enclosure = preg_quote($this->enclosure, '/'); $enclosure = preg_quote($this->enclosure, '/');
if ( preg_match("/".$delimiter."|".$enclosure."|\n|\r/i", $value) || ($value{0} == ' ' || substr($value, -1) == ' ') ) { if ( preg_match("/".$delimiter."|".$enclosure."|\n|\r/i", $value) || ($value{0} == ' ' || substr($value, -1) == ' ') ) {
$value = str_replace($this->enclosure, $this->enclosure.$this->enclosure, $value); $value = str_replace($this->enclosure, $this->enclosure.$this->enclosure, $value);
$value = $this->enclosure.$value.$this->enclosure; $value = $this->enclosure.$value.$this->enclosure;
} }
}
return $value; return $value;
} }