summaryrefslogtreecommitdiff
path: root/src/csvwriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/csvwriter.cpp')
-rw-r--r--src/csvwriter.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/csvwriter.cpp b/src/csvwriter.cpp
index 59a471f..3e2816b 100644
--- a/src/csvwriter.cpp
+++ b/src/csvwriter.cpp
@@ -34,13 +34,47 @@ Bu::CsvWriter::~CsvWriter()
34{ 34{
35} 35}
36 36
37void Bu::CsvWriter::writeLine( const StrArray &aStrs )
38{
39 Bu::FString sBuf;
40 for( StrArray::const_iterator i = aStrs.begin(); i; i++ )
41 {
42 if( i != aStrs.begin() )
43 sBuf += ",";
44 sBuf += sEncode( *i );
45 }
46 sBuf += "\n";
47
48 sOut.write( sBuf );
49}
50
37Bu::FString Bu::CsvWriter::encodeExcel( const Bu::FString &sIn ) 51Bu::FString Bu::CsvWriter::encodeExcel( const Bu::FString &sIn )
38{ 52{
39 return ""; 53 if( sIn.find('\"') )
54 {
55 Bu::FString sOut = "\"";
56 for( Bu::FString::const_iterator i = sIn.begin(); i; i++ )
57 {
58 if( *i == '\"' )
59 sOut += "\"\"";
60 else
61 sOut += *i;
62 }
63 return sOut;
64 }
65 return sIn;
40} 66}
41 67
42Bu::FString Bu::CsvWriter::encodeC( const Bu::FString &sIn ) 68Bu::FString Bu::CsvWriter::encodeC( const Bu::FString &sIn )
43{ 69{
44 return ""; 70 Bu::FString sOut = "";
71 for( Bu::FString::const_iterator i = sIn.begin(); i; i++ )
72 {
73 if( *i == ',' )
74 sOut += "\\,";
75 else
76 sOut += *i;
77 }
78 return sOut;
45} 79}
46 80