英文:
How to print non-ascii character in java?
问题
class P1
{
public static void main(String[] args)
{
System.out.println("在命令提示符中只显示一个问号...");
如果您知道,请帮忙解决。
}
}
英文:
class P1
{
public static void main(String[] args)
{
System.out.println("¢");
}
}
it comes as only one question mark in command prompt...if you know then please help me out.
答案1
得分: 3
Your terminal does not support UTF-8, you're most likely running Windows. Google to see how to change that.
英文:
Your terminal does not support UTF-8, you're most likely running Windows. Google to see how to change that.
答案2
得分: 1
问题几乎肯定与您的默认控制台/IDE可以显示的字符有关。即使在屏幕上显示,UTF 字符也需要启用 UTF 的字体才能正确呈现。
在 GitHub 上可能有一些Java UTF文本编辑器,您可以将其用作控制台替代品。然后,您需要一个OutputStream,它将附加到文本编辑器面板(我多年前创建了类似的东西:https://sourceforge.net/p/tus/code/HEAD/tree/tjacobs/TextAreaOutputStream.java),然后您需要使用
System.setOut
和
System.setErr
与您的流一起使用。
英文:
The problem is almost certainly with the characters your default console/ide can display. Even when displayed on the screen, utf characters need a utf enabled font for them to render correctly.
There are probably Java UTF text editors on GitHub that you could use as a console replacement. Then what you need is an OutputStream that will append to the text editor panel (I created something of this ilk years ago: https://sourceforge.net/p/tus/code/HEAD/tree/tjacobs/TextAreaOutputStream.java) and then you need to use
System.setOut
and
System.setErr
With your Stream
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论