Subject: | escape_char before characters that do not need to be escaped. |
Hello,
I'd like to make a comment about an aspect of Text::CSV_XS design. When you escape a character that do not need to be escaped (i.e. not quote_char, escape_char, sep_char), a failure code is returned by the decoder. I think it could be more interesting to have the possibility to ignore this kind of error.
I had to work with this kind of csv: (separator ';', escape '\')
"Example";"It\'s an apostrophee"
I did a quick modification to the module that seemed to work, but I did not do a lot of tests (the patch is for version 0.23). The idea is that any character can be escaped, even though it is useless for most.
Sincerely,
Francois Secherre
Les fichiers Text-CSV_XS-0.23/blib/arch/auto/Text/CSV_XS/CSV_XS.so et Text-CSV_XS-0.23patch/blib/arch/auto/Text/CSV_XS/CSV_XS.so sont différents.
diff -ru Text-CSV_XS-0.23/CSV_XS.c Text-CSV_XS-0.23patch/CSV_XS.c
--- Text-CSV_XS-0.23/CSV_XS.c 2005-10-16 08:55:30.783097072 -0400
+++ Text-CSV_XS-0.23patch/CSV_XS.c 2005-10-16 08:08:24.206801984 -0400
@@ -417,14 +417,8 @@
ERROR_INSIDE_QUOTES;
} else if (c2 == '0') {
CSV_PUT_SV(insideQuotes, (int) '\0');
- } else if (c2 == csv->quoteChar || c2 == csv->sepChar ||
- c2 == csv->escapeChar) {
- /* c2 == csv->escapeChar added 28-06-1999,
- * Pavel Kotala <pkotala@logis.cz>
- */
- CSV_PUT_SV(insideQuotes, c2);
} else {
- ERROR_INSIDE_QUOTES;
+ CSV_PUT_SV(insideQuotes, c2);
}
} else if (insideField) {
int c2 = CSV_GET;
Seulement dans Text-CSV_XS-0.23patch/: CSV_XS.c~
Les fichiers Text-CSV_XS-0.23/CSV_XS.o et Text-CSV_XS-0.23patch/CSV_XS.o sont différents.