# [java] Unicode Question

This topic is 4669 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I want a program that can accept Unicode characters as input and output them to the screen, I had heard that Java supported double-byte characters by default (which is why I am attempting to port this project to Java from C++) but I have found only vague references to it in tutorials and books. Like say I try to create a string with Unicode characters in the constructor: String abs = new String("おほようございます","ISO8859_1"); This should work shouldn't it? But it doesn't, instead of おほようございます I'm getting a series of squares and the compiler flags it as an error. Is the problem with NetBeans IDE 3.6 or is it the language itself?

##### Share on other sites
Hi,

I usually do the following in networking code:

URLEncoder.encode(new String("international string", "iso-8859-1"), "iso-8859-1");

Which is, of course, bad programming, but it works just fine. I had several similar problems with character encoding, and I have searched a lot for a good tutorial that could clear my doubts, but with no success at all.

Son Of Cain

##### Share on other sites
You cannot type the literal characters into your source file and have them work; Java does support the data natively with its data types and classes (char, java.lang.String etc.), but the source file is expected to be encoded in Latin-1.

To represent those characters, escape them with \u#### (four hex digits) sequences.