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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]