The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Input of unicode from TextArea

Posted by Matt Gerrans on October 26, 2001 at 5:58 PM

> I want to input unicode from a TextArea as \udddd but getText
> interprets \udddd as a 6 element string. I have tried recreating
> the code from this string by getChars and creating a new string
> but it always comes out as a 6 element string rather than a
> 1 element unicode string. There is no problem with the internal
> creation of a unicode character by assignment in the Java program.

Of course. If you want "\udddd" in your text to be converted to a unicode character, you need to interpret the input and do the conversion. If you type Java code into the TextArea, you don't expect it to figure that out and give you compiled bytecodes as a results, either.

If you are looking for automatic unicodification (I made that word up!), you may look into the documentation the "Writer" stream objects, which handle character to byte type of conversions.

If you are using a US or European keyboard and you are trying to enter unicode, then you can look for tools to help with that, or you can enter the binary codes (if you know them) directly into editor (it may even work in your TextArea). On the Windows platforms, you enter extended binary by holding down the Alt key and typing in the 3-digit value of each byte on the number keypad (not with the numbers above the letter keys); unicode would be two bytes per character, of course (Arabic letters being preceded by a decimal 000 byte).

- mfg


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us