We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 73147a9 commit d42b2d2Copy full SHA for d42b2d2
lib/csv-utils.ts
@@ -4,8 +4,8 @@
4
export function tableToCSV(columns: string[], rows: string[][]): string {
5
// 轉義 CSV 欄位中的特殊字符
6
const escapeCSVField = (field: string): string => {
7
- // 如果欄位包含逗號、雙引號或換行符,需要用雙引號包圍
8
- if (field.includes(",") || field.includes("\"") || field.includes("\n")) {
+ // 如果欄位包含逗號、雙引號、換行符或回車符,需要用雙引號包圍
+ if (field.includes(",") || field.includes("\"") || field.includes("\n") || field.includes("\r")) {
9
// 將雙引號轉義為兩個雙引號
10
return `"${field.replace(/"/g, "\"\"")}"`;
11
}
0 commit comments