Cassidy Laidlaw
Cassidy Laidlaw

Reputation: 1368

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. I've tried using System.console().writer() to output as well as just System.out, but they both produce the same result. It seems that maybe I need a different charset?

Upvotes: 1

Views: 1020

Answers (2)

Cassidy Laidlaw
Cassidy Laidlaw

Reputation: 1368

What was wrong in the end was the character encoding setting in Console.app. I went to the preferences and changed that to "Western (Mac OS Roman)" and it worked fine after that.

Upvotes: 0

Richard Campbell
Richard Campbell

Reputation: 3621

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).

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\u00F6 W\u00F6rld!" for "Hellö Wörld!"

The following link will convert a string with unicode characters into escaped literals: http://www.snible.org/java2/uni2java.html

Upvotes: 1

Related Questions