我用 node.js 生成了一个 utf-8 编码的 csv,然后我在 Windows 上双击打开它。Excel 启动,但某些特殊字符(如 Ä、Ö、Ü、ä、ö、ü ...)未正确显示。我认为这是由于错误的编码。我保存了一个用 excel 创建的新 csv。我看到编码是windows-1252。
我google了很多,尝试了很多,但没有解决方案。
我尝试使用 https://github.com/mathiasbynens/windows-1252 和 https://github.com/kvz/phpjs/tree/master/functions/xml的组合
data = helper.utf8_encode(data);
data = helper.utf8_decode(data);
data = windows1252.encode(data);
data = windows1252.decode(data);
data = helper.utf8_encode(windows1252.encode(data));
data = helper.utf8_encode(windows1252.decode(data));
data = helper.utf8_decode(windows1252.encode(data));
data = helper.utf8_decode(windows1252.decode(data));
data = windows1252.encode(helper.utf8_encode(data));
data = windows1252.decode(helper.utf8_encode(data));
data = windows1252.encode(helper.utf8_decode(data));
data = windows1252.decode(helper.utf8_decode(data));
但没有任何效果。请帮我
更新:通过修补,我发现这些代码显示为希望的字符,但仍然缺少小写的äöü。有人知道吗?
\u0101 => Ä
\u010D => Ä
\u011D => Ä
\u0120 => Ä
\u0581 => Ö
\u058D => Ö
\u058F => Ö
\u0590 => Ö
\u059D => Ö
\u05A0 => Ö
\u0701 => Ü
\u070D => Ü
\u070F => Ü
\u0710 => Ü
\u071D => Ü
\u0720 => Ü
\u07C1 => ß
\u07CD => ß
\u07D0 => ß
\u07DD => ß
\u07E0 => ß