修复编码和空字段显示问题
- 优先使用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:
parent
997ce9022c
commit
7870366502
@ -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)
|
||||
|
||||
@ -45,23 +45,14 @@ namespace SlideCombine
|
||||
// Volume行
|
||||
result.AppendLine($"Volume:{Volume}");
|
||||
|
||||
// ISBN行
|
||||
if (!string.IsNullOrEmpty(ISBN))
|
||||
{
|
||||
result.AppendLine($"ISBN:{ISBN}");
|
||||
}
|
||||
// ISBN行 - 即使为空也要输出
|
||||
result.AppendLine($"ISBN:{ISBN}");
|
||||
|
||||
// Creator行
|
||||
if (!string.IsNullOrEmpty(Creator))
|
||||
{
|
||||
result.AppendLine($"creator:{Creator}");
|
||||
}
|
||||
// Creator行 - 即使为空也要输出
|
||||
result.AppendLine($"creator:{Creator}");
|
||||
|
||||
// Contributor行
|
||||
if (!string.IsNullOrEmpty(Contributor))
|
||||
{
|
||||
result.AppendLine($"contributor:{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))
|
||||
{
|
||||
result.AppendLine($"spatial:{Spatial}");
|
||||
}
|
||||
// Spatial行 - 即使为空也要输出
|
||||
result.AppendLine($"spatial:{Spatial}");
|
||||
|
||||
// Other ISBN行
|
||||
if (!string.IsNullOrEmpty(OtherISBN))
|
||||
{
|
||||
result.AppendLine($"Other ISBN:{OtherISBN}");
|
||||
}
|
||||
// Other ISBN行 - 即使为空也要输出
|
||||
result.AppendLine($"Other ISBN:{OtherISBN}");
|
||||
|
||||
// Other time行
|
||||
if (!string.IsNullOrEmpty(OtherTime))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user