修复编码和空字段显示问题

- 优先使用GBK编码读取TXT文件,解决中文显示问号问题
- 确保所有字段都输出,包括空值字段(ISBN, creator, contributor, spatial, Other ISBN)
- 与示例文件格式保持完全一致

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
yuuko 2025-11-24 15:54:05 +08:00
parent 997ce9022c
commit 7870366502
2 changed files with 14 additions and 27 deletions

View File

@ -157,11 +157,13 @@ namespace SlideCombine
string[] lines;
try
{
lines = File.ReadAllLines(txtFile, Encoding.UTF8);
// 先尝试GBK编码因为示例文件是中文的
lines = File.ReadAllLines(txtFile, Encoding.GetEncoding("GBK"));
}
catch
{
lines = File.ReadAllLines(txtFile, Encoding.GetEncoding("GBK"));
// 如果GBK失败再尝试UTF-8
lines = File.ReadAllLines(txtFile, Encoding.UTF8);
}
foreach (var line in lines)

View File

@ -45,23 +45,14 @@ namespace SlideCombine
// Volume行
result.AppendLine($"Volume:{Volume}");
// ISBN行
if (!string.IsNullOrEmpty(ISBN))
{
// ISBN行 - 即使为空也要输出
result.AppendLine($"ISBN:{ISBN}");
}
// Creator行
if (!string.IsNullOrEmpty(Creator))
{
// Creator行 - 即使为空也要输出
result.AppendLine($"creator:{Creator}");
}
// Contributor行
if (!string.IsNullOrEmpty(Contributor))
{
// Contributor行 - 即使为空也要输出
result.AppendLine($"contributor:{Contributor}");
}
// IssuedDate行
result.AppendLine($"issuedDate:{IssuedDate}");
@ -104,17 +95,11 @@ namespace SlideCombine
result.AppendLine($"date:{Date}");
}
// Spatial行
if (!string.IsNullOrEmpty(Spatial))
{
// Spatial行 - 即使为空也要输出
result.AppendLine($"spatial:{Spatial}");
}
// Other ISBN行
if (!string.IsNullOrEmpty(OtherISBN))
{
// Other ISBN行 - 即使为空也要输出
result.AppendLine($"Other ISBN:{OtherISBN}");
}
// Other time行
if (!string.IsNullOrEmpty(OtherTime))