Unicode 字符(阿拉伯字母)在 IDE 控制台中显示为问号 [英] Unicode characters (Arabic letters) show up as question marks in IDE console

查看:27
本文介绍了Unicode 字符(阿拉伯字母)在 IDE 控制台中显示为问号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 JSF 2.0 并且我的文本字段为

I am using JSF 2.0 and I have text field as

<h:form>
    <h:inputText value="#{myBean.myValue}" />
    <h:commandButton value="Submit" action="#{myBean.printMe()}" />
</h:form>

public void printMe() {
    System.out.println("first line==" + myValue + "==");
    System.out.println("second line==يشسيبشسيبشسيبشيس==");
}

当我运行这个项目并在文本框中输入 يشسيبشسيبشسيبشيس 时,在 IDE 控制台中我看到如下.

When I run this project and enter يشسيبشسيبشسيبشيس in textbox, in IDE console I see as below.

INFO: first line==????????????????==
INFO: second line==????????????????==

知道为什么会这样吗?

推荐答案

这是由于使用了错误的控制台编码造成的.

This is caused by using the wrong console encoding.

线

System.out.println("My Data is " + fullName);

打印到标准输出 (stdout).您还需要将其配置为使用 UTF-8.假设您使用的是 Eclipse,那么您需要通过 Window > 将 stdout 编码更改为 UTF-8.首选项 >一般>工作区文本文件编码.

prints to the standard output (stdout). You need to configure it to use UTF-8 as well. Assuming that you're using Eclipse, then you need to change the stdout encoding to UTF-8 by Window > Preferences > General > Workspace > Text File Encoding.

如果您使用的是 Netbeans,我无法从头开始回答,请前往以下答案:希伯来语在 netbeans 中显示为问号,其中包含指向此 Netbeans Wiki 的链接 其中提到了以下内容:

If you're using Netbeans, which I can't answer from top of head, head to this answer: hebrew appears as question marks in netbeans which contains a link to this Netbeans Wiki which mentions the following:

要更改项目的语言编码:

To change the language encoding for a project:

  1. 右键单击项目"窗口中的项目节点,然后选择属性".
  2. 在来源下,从编码下拉字段中选择一个编码值.

另见:

  • Unicode - 如何正确获取字符?
  • 与具体问题无关,过滤器中的那些行是不必要的

    Unrelated to the concrete problem, those lines in the filter are unnecessary

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

    在 JSF2/Facelets 的情况下,它们已经默认为正确的值.删除这些行.

    They defaults in case of JSF2/Facelets to proper values already. Remove those lines.

    这篇关于Unicode 字符(阿拉伯字母)在 IDE 控制台中显示为问号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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