From 582c1338356d7079cf7795f731fb6b55b1a97999 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 24 Jul 2022 20:51:09 +0100 Subject: [PATCH] CSV escaping. --- common/string_utils.cpp | 9 +++++++++ include/string_utils.h | 1 + 2 files changed, 10 insertions(+) diff --git a/common/string_utils.cpp b/common/string_utils.cpp index 28351580f7..5bdf0cb971 100644 --- a/common/string_utils.cpp +++ b/common/string_utils.cpp @@ -245,6 +245,15 @@ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext ) else converted += c; } + else if( aContext == CTX_CSV ) + { + if( c == ',' ) + converted += wxT( "{comma}" ); + else if( c == '\n' || c == '\r' ) + converted += wxT( "{return}" ); + else + converted += c; + } else { converted += c; diff --git a/include/string_utils.h b/include/string_utils.h index f41e128ec8..40a0e0fa76 100644 --- a/include/string_utils.h +++ b/include/string_utils.h @@ -56,6 +56,7 @@ enum ESCAPE_CONTEXT CTX_IPC, CTX_QUOTED_STR, CTX_LINE, + CTX_CSV, CTX_FILENAME, CTX_NO_SPACE // to replace spaces in names that do not accept spaces };