[英]How to output accented characters from Java on a Mac?
I'm trying to output accented characters from java into the Console app on a mac, however they just show up as ?'s. 我正在尝试将重音符号从Java输出到Mac上的Console应用程序中,但是它们只是显示为?。 I've tried using System.console().writer() to output as well as just System.out, but they both produce the same result. 我尝试使用System.console()。writer()以及System.out进行输出,但是它们都产生相同的结果。 It seems that maybe I need a different charset? 看来我可能需要其他字符集?
If you are seeing '?'s from the console, the console font you are using does not support those characters. 如果从控制台看到“?”,则说明您使用的控制台字体不支持这些字符。 Try switching the font of the console (you might try Trebuchet MS, or Century). 尝试切换控制台的字体(您可以尝试Trebuchet MS或Century)。
EDIT: If you think the source is incorrect, you might try modifying it to use Java unicode escape characters in the string literal, ala "Hell\ö W\örld!" 编辑:如果您认为源不正确,则可以尝试将其修改为在字符串文字ala“ Hell \\ u00F6 W \\ u00F6rld!”中使用Java unicode转义字符! for "Hellö Wörld!" 为“HellöWörld!”
The following link will convert a string with unicode characters into escaped literals: http://www.snible.org/java2/uni2java.html 以下链接会将带有Unicode字符的字符串转换为转义的文字: http : //www.snible.org/java2/uni2java.html
What was wrong in the end was the character encoding setting in Console.app. 最后的问题是Console.app中的字符编码设置。 I went to the preferences and changed that to "Western (Mac OS Roman)" and it worked fine after that. 我转到首选项,然后将其更改为“ Western(Mac OS Roman)”,此后效果很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.