HuaHuaY commented on code in PR #50846:
URL: https://github.com/apache/arrow/pull/50846#discussion_r3827137074


##########
cpp/src/arrow/csv/writer.cc:
##########
@@ -167,16 +167,32 @@ class ColumnPopulator {
 
 // Copies the contents of s to out properly escaping any necessary characters.
 // Returns the position next to last copied character.
-char* Escape(std::string_view s, char* out) {
+char* Escape(std::string_view s, char* out, EscapeStyle escape_style) {
   for (const char c : s) {
+    if (c == '"' && escape_style == EscapeStyle::Backslash) {
+      *out++ = '\\';
+    }
     *out++ = c;
-    if (c == '"') {
+    if (c == '"' && escape_style == EscapeStyle::Double) {
       *out++ = '"';
     }
   }
   return out;
 }
 
+// Returns the number of characters needed to escape the given string.
+int64_t EscapedLength(std::string_view s, EscapeStyle escape_style) {
+  int64_t quote_count = static_cast<int64_t>(std::count(s.begin(), s.end(), 
'"'));

Review Comment:
   
   ```suggestion
     int64_t quote_count = CountQuotes(s);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to