Java:无法保存为UTF-8 [英] Java: can't save in UTF-8

查看:386
本文介绍了Java:无法保存为UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在java中有这行代码:

I have this line of code in java:

new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name, append), "UTF-8"));

此编写器不会写入UTF-8文件,因为当我在记事本++中打开它时,编码为:ANSI为UTF-8。我需要它是纯UTF-8。

This writer does not write an UTF-8 file, because when I open it in notepad++ it says that the encoding is: ANSI as UTF-8. I need it to be pure UTF-8.

你有什么建议吗?

推荐答案

notepad ++(和任何其他工具)只能猜测编码,它不会写入文件(或某些元数据)的任何位置。

notepad++ (and any other tool) can only guess the encoding, it's not written anywhere in your file (or in some metadata).

如果您编写的文本不包含任何超出ASCII范围的字符(即没有Unicode码点大于127的字符),那么具有ANSI编码的文件与UTF-8编码中的文件不可区分。

And if the text you've written doesn't contain any characters outside the ASCII range (i.e. no character with a Unicode codepoint > 127), then a file with ANSI encoding is indistinguishable from one in UTF-8 encoding.

这篇关于Java:无法保存为UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆