Eclipse字符编码 [英] Eclipse character encoding
问题描述
我使用Scanner在Java中扫描.txt文档。但是,当我在Eclipse中打开.txt文档时,我注意到一些字符未被识别,并且它们被替换为类似这样的东西:
p>
这些字符甚至不会让我将文件扫描为
while (scan.hasNext)
自动返回false(如果这些字符不存在,文档很好)。
那么,如何让Eclipse识别这些字符,以便我可以扫描?我无法手动删除它们,因为文档相当大。
感谢。
您正在阅读的文件必须包含UTF-8或其他编码字符,尝试打印他们在控制台,那么你会得到一些chracters作为 '。这是因为defualt控制台编码不是eclipse中的UTF-8。您需要通过在下拉菜单中运行配置 - >常用 - >编码 - >选择UTF-8进行设置。检查belo屏幕截图:
/ p>
I am using Scanner to scan a .txt document in Java. However, when I open the .txt document in Eclipse, I notice some characters are not being recognized, and they are replaced with something that looks like this:
�
These characters won't even let me scan the file as
while(scan.hasNext)
automatically returns false (if these characters are not present, then I can scan the document just fine).
So, how do I get Eclipse to recognize these characters so I can scan? I can't manually remove them because the document is quite large. Thanks.
The file you are reading must be containg UTF-8 or some other encoding characters and when you try to print them on on console then you will get some chracters as �'. This is because the defualt console encoding is not UTF-8 in eclipse. You need to set it by going to Run Configuration -> Common -> Encoding -> Select UTF-8 formthe drop down. Check belo screenshot:
这篇关于Eclipse字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!