在 Windows 7 中查看 Java Unicode [英] View Java Unicode in Windows 7

查看:34
本文介绍了在 Windows 7 中查看 Java Unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个尝试输出某些 Unicode 字符(例如,U+2660 到 U+2663)的 Java 程序.在 Windows 7 中工作,在任何情况下我都无法成功查看这些符号.我尝试过的上下文:

I'm working on a Java program that attempts to output certain Unicode characters (for example, U+2660 through U+2663). Working in Windows 7, under no circumstances can I successfully view these symbols. Contexts I've tried:

  • 在我的 jGRASP IDE 中.
  • 在 Windows 命令提示符中.
  • 通过打印到文本文件.

有什么办法可以成功查看这些字符吗?

Is there any way at all to successfully view these characters?

推荐答案

在 Windows 上没有真正的方法可以做到这一点.使用 Linux 是最简单的解决方案.

There is no real way to do this on Windows. Using Linux is the easiest solution.

Windows 控制台排序支持 UTF-8,Java 排序支持更改编码.所以你可以这样做:

The Windows console sort-of supports UTF-8 and Java sort-of supports changing the encoding. So you can do this:

在Windows控制台中,使用Properties上下文菜单将字体设置为Lucida Console(可以显示很多Unicode字符),然后:

In the Windows console, use the Properties context menu to set the font to Lucida Console (which can display a lot of Unicode characters), then:

  • chcp 65001

java -Dfile.encoding=UTF-8 MyProgram

当我在 Windows 7 上执行此操作时,每个 printprintln 的最后两个字符都会重复,但除此之外似乎还可以.

When I do this on Windows 7, the last two characters of each print or println are repeated, but otherwise it seems to work.

请注意,这也会将程序中文件 I/O 的默认编码更改为 UTF-8.

Note that this will also change the default encoding for file I/O in your program to UTF-8.

我刚刚注意到您的第三类打印到文本文件".是的,打开文本文件以 UTF-8(或任何支持 Unicode 的编码)写入.然后,在编辑器中查看它(如果没有 BOM 并且它不是系统默认编码,您可能需要在打开时指定编码 - 您可以使用 jGRASP 中的文件">打开"来执行此操作)并使用可以显示字符的字体.

I just noticed your third category "printing to a text file". Yes, open the text file for writing in UTF-8 (or any encoding that supports Unicode). Then, view it in an editor (you may need to specify the encoding when opening if there is no BOM and it is not the system default encoding - you can do this with "File" > "Open" in jGRASP) and view using a font that can display the characters.

这篇关于在 Windows 7 中查看 Java Unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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