UTF-8 characters are missing or displayed as blocks in Notepad, but work fine in a web browser and other text editors

I have UTF-8 text stored in a database and used as text/plain; charset=utf-8 text/plain; charset=utf-8 in a web application. Everything is working fine. I see UTF-8 text in a browser window without any problems.

But when I save this text in a file and try to open it in Windows Notepad, I have some characters that are missing and displayed as a rectangular rectangle. However, the text file looks great in other editors such as EditPlus and Notepad ++.

How is this caused and how can I solve it?

+4
source share
3 answers

If it looks good in other editors, then the text itself is fine. If it looks fine in the browser, then the answer is probably fine too (but it’s better to check the page information in the browser and see what the encoding is). Your problem is probably with the recording itself. Sometimes this requires a Unicode specification specification. But the BOM may break other applications that do not support it. You should also try Notepad on different versions of Windows. I just tried opening a UTF-8 file in Windows 7, it looks good to me.

+3
source

If you use tomcat as an application server, you can add it to your configuration: "-Dfile.encoding = UTF-8"

Also, look here: Setting the default Java character encoding?

-2
source

You need to use as below:

response.setContentType ("text / html; charset = utf-8"); response.setCharacterEncoding ("UTF-8");

-2
source

All Articles