Eclipse 字符编码

Eclipse character encoding(Eclipse 字符编码)
本文介绍了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 字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How can create a producer using Spring Cloud Kafka Stream 3.1(如何使用Spring Cloud Kafka Stream 3.1创建制片人)
Insert a position in a linked list Java(在链接列表中插入位置Java)
Did I write this constructor properly?(我是否正确地编写了这个构造函数?)
Head value set to null but tail value still gets displayed(Head值设置为空,但仍显示Tail值)
printing nodes from a singly-linked list(打印单链接列表中的节点)
Control namespace prefixes in web services?(控制Web服务中的命名空间前缀?)