You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Copilot (via GitHub)" <gi...@apache.org> on 2026/08/12 05:20:36 UTC
Re: [PR] GH-30431: [C++] Add EscapeStyle to CSV Writer for configurable escape control [arrow]
Copilot commented on code in PR #50846:
URL: https://github.com/apache/arrow/pull/50846#discussion_r3763794035
##########
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) {
Review Comment:
`EscapedLength` returns the total output length after applying escaping rules, not the number of extra characters needed. The current comment is ambiguous and can be read as returning only the additional escape characters.
This issue also appears on line 384 of the same file.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org