我正在使用 Super CSV 创建 CSV 文件。当我编写特殊字符(如元音变音字符 ï
或 î
)时,当我使用 Excel 打开生成的 CSV 时,它会在生成的 CSV 中中断。当我使用 Notepad++ 打开同一文件时,它完美地显示了元音变音字符。
知道可能是什么原因吗?我已经指定UTF-8编码。我有什么遗漏的吗?
ICsvListWriter writer = new CsvListWriter(
getWriter(getCUSTOMEREXPORT_FOLDERPATH()+filename),
CsvPreference.STANDARD_PREFERENCE);
private static OutputStreamWriter getWriter(String fileName) {
final File file = new File(fileName);
return new OutputStreamWriter(new FileOutputStream(file),
Charset.forName("UTF-8"));
}
最佳答案
微软及其 Excel 对于 UTF-8 来说太愚蠢了。 Excel 严格要求字节顺序标记才能意识到这实际上是 UTF-8。添加它就可以了。
关于java - Excel 不显示使用 Super CSV 创建的 CSV 文件中的变音字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20493358/