Eclipse character encoding(Eclipse 字符编码)
问题描述
我正在使用 Scanner 扫描 Java 中的 .txt 文档.但是,当我在 Eclipse 中打开 .txt 文档时,我注意到一些字符无法识别,并且它们被替换为如下所示的内容:
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)
自动返回false(如果这些字符不存在,那么我可以扫描文档就好了).
automatically returns false (if these characters are not present, then I can scan the document just fine).
那么,我如何让 Eclipse 识别这些字符以便我可以扫描?我无法手动删除它们,因为文档很大.谢谢.
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.
推荐答案
您正在阅读的文件必须包含 UTF-8 或其他一些编码字符,当您尝试在控制台上打印它们时,您会得到一些字符为'.这是因为 eclipse 中默认的控制台编码不是 UTF-8.您需要通过转到运行配置 -> 通用 -> 编码 -> 从下拉列表中选择 UTF-8 来设置它.检查以下屏幕截图:
The file you are reading must be containing UTF-8 or some other encoding characters and when you try to print them on console then you will get some characters as �'. This is because the default console encoding is not UTF-8 in eclipse. You need to set it by going to Run Configuration -> Common -> Encoding -> Select UTF-8 from the drop down. Check below screenshot:
这篇关于Eclipse 字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Eclipse 字符编码


基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01