huangzengtian commented on issue #846:
URL: https://github.com/apache/fesod/issues/846#issuecomment-3851297710
> Regarding the suggestion to set `quote` to null, please feel free to
submit a pull request at any time to enhance this parameter setting.
针对这个优化,我分析发现问题的本质在于 quote() 配置项的 null 具有二义性:系统无法分辨用户是忽略了该配置(应使用默认值
")还是显式想禁用引号处理。
我建议通过以下最小改动来实现:
在 CsvConstant 中增加:
```
/**
* Represents a disabled quote character.
* When the quote is set to this value, the CSV parser will treat all
quote characters as regular text.
*/
public static final char NONE_QUOTE = '\0';
```
在 CsvReaderBuilder#quote(Character qutote) 增加说明
```
/**
* Sets the quote character
* <p>
* If set to {@link
org.apache.fesod.sheet.metadata.csv.CsvConstant#NONE_QUOTE}, the quote parsing
logic will be disabled,
* and quote characters will be treated as regular text.This is equivalent
to setting
* {@code quote} to {@code null} in Apache Commons CSV.
* </p>
*
* @param quote the quote character
* @return Returns a CsvReaderBuilder object, enabling method chaining
*/
public CsvReaderBuilder quote(Character quote) {
return quote(quote, QuoteMode.MINIMAL);
}
```
另外我去看了 CSV 的[标准规范(RFC
4180)](https://datatracker.ietf.org/doc/rfc4180/)。2.7里面规定:**如果字段内部出现引号,必须成对出现(即用双引号
"" 表示一个引号)**。
<img width="796" height="456" alt="Image"
src="https://github.com/user-attachments/assets/0e2e3319-6d1d-44b3-8718-d92913bed909"
/>
而 亚马逊生成的CSV报告文档没有遵循这条规定(直接没有对引号转义):
- 15" Monitor (这里引号表示英寸) ,按照CSV标准应该为 `"15"" Monitor"` ,实际为 `"15" Monitor "`
- Joe's "Special" Gift (这里引号表示强调词),按照CSV标准应该为 `"Joe's ""Special"" Gift
"`,实际为 `"Joe's "Special" Gift"`
这下我的疑惑彻底解开了,感谢你的回复。
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]