summaryrefslogtreecommitdiff
path: root/src/csvwriter.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-22 21:08:25 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-22 21:08:25 +0000
commita41a8d21e9f7fde7c69c1748a76c9058b58ebaf3 (patch)
treeb99d33ba81331df03acd369898f34d49d0bd2a84 /src/csvwriter.cpp
parent38d72457609b56c1b0f8e82d719e44f9906fe9c0 (diff)
downloadlibbu++-a41a8d21e9f7fde7c69c1748a76c9058b58ebaf3.tar.gz
libbu++-a41a8d21e9f7fde7c69c1748a76c9058b58ebaf3.tar.bz2
libbu++-a41a8d21e9f7fde7c69c1748a76c9058b58ebaf3.tar.xz
libbu++-a41a8d21e9f7fde7c69c1748a76c9058b58ebaf3.zip
Minor change to csvwriter, the excel formatter wasn't escaping strings with
commas or quotes quite right, it's much better now. Also, added an SHA1 unit test.
Diffstat (limited to 'src/csvwriter.cpp')
-rw-r--r--src/csvwriter.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/csvwriter.cpp b/src/csvwriter.cpp
index 58437b8..d8910aa 100644
--- a/src/csvwriter.cpp
+++ b/src/csvwriter.cpp
@@ -50,7 +50,7 @@ void Bu::CsvWriter::writeLine( const StrArray &aStrs )
50 50
51Bu::String Bu::CsvWriter::encodeExcel( const Bu::String &sIn ) 51Bu::String Bu::CsvWriter::encodeExcel( const Bu::String &sIn )
52{ 52{
53 if( sIn.find('\"') ) 53 if( sIn.find('\"') || sIn.find(',') )
54 { 54 {
55 Bu::String sOut = "\""; 55 Bu::String sOut = "\"";
56 for( Bu::String::const_iterator i = sIn.begin(); i; i++ ) 56 for( Bu::String::const_iterator i = sIn.begin(); i; i++ )
@@ -60,6 +60,7 @@ Bu::String Bu::CsvWriter::encodeExcel( const Bu::String &sIn )
60 else 60 else
61 sOut += *i; 61 sOut += *i;
62 } 62 }
63 sOut += '\"';
63 return sOut; 64 return sOut;
64 } 65 }
65 return sIn; 66 return sIn;