Skip to content

Commit

Permalink
修复了UTF-8格式下输出的内容中文乱码问题
Browse files Browse the repository at this point in the history
Signed-off-by: Detrital <[email protected]>
  • Loading branch information
Detritalw authored Dec 21, 2024
1 parent 40d9fe4 commit b55491f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
6 changes: 4 additions & 2 deletions Class-Widget-CSV-import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ void NumCsv2Json(HWND hWnd, HWND hEdit) {
// 构建输出文件路径
wstring outputFilePath = filePath.substr(0, filePath.find_last_of(L"\\/") + 1) + L"课表.json";

// 打开输入文件
// 打开输入文件,使用 UTF-8 编码
wifstream inputFile(filePath.c_str());
inputFile.imbue(locale(locale(), new codecvt_utf8<wchar_t>));
if (!inputFile.is_open()) {
MessageBoxW(hWnd, L"无法打开输入文件", L"请检查文件路径", MB_OK | MB_ICONERROR);
return;
}

// 创建输出文件
// 创建输出文件,使用 UTF-8 编码
wofstream outputFile(outputFilePath.c_str());
outputFile.imbue(locale(locale(), new codecvt_utf8<wchar_t>));
if (!outputFile.is_open()) {
MessageBoxW(hWnd, L"无法创建输出文件", L"请检查文件路径", MB_OK | MB_ICONERROR);
return;
Expand Down
Binary file added Class-Widget-CSV-import.exe
Binary file not shown.
16 changes: 8 additions & 8 deletions a.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
2,
AM,8,30
PM,13,10
35,�μ�,a1,a2,a3,a4,a5,a6,a7,
55,�γ�,b1,b2,b3,b4,b5,b6,b7,
65,�μ�,c1,c2,c3,c4,c5,c6,c7,
75,�γ�,d1,d2,d3,d4,d5,d6,d7,
85,�μ�,e1,e2,e3,e4,e5,e6,e7,
95,�γ�,f1,f2,f3,f4,f5,f6,f7,
上午,8,30
下午,13,10
35,课间,a1,a2,a3,a4,a5,a6,a7,
55,课程,b1,b2,b3,b4,b5,b6,b7,
65,课间,c1,c2,c3,c4,c5,c6,c7,
75,课程,d1,d2,d3,d4,d5,d6,d7,
85,课间,e1,e2,e3,e4,e5,e6,e7,
95,课程,f1,f2,f3,f4,f5,f6,f7,
4 changes: 2 additions & 2 deletions right课表.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
]
},
"part_name": {
"0": "AM",
"1": "PM"
"0": "上午",
"1": "下午"
}
}
4 changes: 2 additions & 2 deletions 课表.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"1": [13, 10]
},
"part_name": {
"0": "AM",
"1": "PM"
"0": "上午",
"1": "下午"
}
}

0 comments on commit b55491f

Please sign in to comment.