简体   繁体   English

如何在Mac上从Java输出重音字符?

[英]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.

相关问题 如何在电子邮件的TO和FROM中允许带重音的字符(支持UTF-8)? - How to allow accented characters(UTF-8 supported) characters in TO and FROM of an email? 从Java代码创建bat并保持撇号和重音字符 - Create bat from java code keeping apostrophes and accented characters 从 Java 字符串中删除格式,同时保留重音字符 - Remove formatting from Java String while retaining accented characters 将Java程序中的重音字符打印到linux shell - Printing accented characters from a Java program onto a linux shell 带有重音字符的 Java 属性文件 - Java Properties File with accented characters 在 Java 中读取带有重音字符的文件 - reading file with accented characters in Java 如何在Java中将重音符号转换为HTML符号? - How can I convert accented characters to HTML symbol in Java? 如何使用Servlet和MySQL正确读取Java中的重音字符? - How to correctly read accented characters in Java with Servlets and MySQL? 如何使用正则表达式防止 Java 中的 email 字段中的重音字符? - How to prevent accented characters in an email field in Java using regex? 如何使用扫描仪以正确的方式读取文件中的重音字符? - How to use scanner to read accented characters from file in correct way?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM