This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Java "String" are unicode. Can you try rewording your request? If you have a String, its unicode. If you want to insert a special character, you look up the character and escape it, exactly the way you show in your question.
You want to convert the string "\u00ea" (which has 1 character) to the string "\\u00ea" (which has 6 characters)? Start with this:
Joined: Jul 01, 2003
Thanks to Paul and Pat for your kindness. It helps me a lot specially dealing with the hex.
If If have a numerical value of an int 192, its hex value is c0. How do I convert this numerical value into a special character?
For value of 256 or higher, when I cast that number to char, I just see [?]. I wonder that I have to set some sort of UTF8 but don't know how. Could you show me how to set the output stream? Thank you very much. You all have given a big help.
If you want to verify characters outside your default character set, you can check them with Swing:Which characters you can display in a console depends on your environment. A modern Linux distribution will use UTF-8 for xterm, etc., but I don�t think Windows consoles can display Unicode at all.
Originally posted by John McDonald: If If have a numerical value of an int 192, its hex value is c0. How do I convert this numerical value into a special character?
For value of 256 or higher, when I cast that number to char,
The upthread example shows how to do general unicode special characters.
just replace the 00ea with whatever you need.
Seeing Unicode is another matter. You have to have the proper language character fonts installed, and you have to know how to read them. For 90% of the world's languages that don't use something Roman, I have no idea what a character is supposed to look like.
When you had that "c0" which you wanted to convert to Unicode, did you have any idea of what result you should be expecting? It sort of sounds to me like you're fishing in the dark. Go and have a look through the Unicode code charts. Start by looking at the ones named "Latin something".
Joined: Jul 01, 2003
My question was if I have a value of 192, how do I change this value of special A character. So the answer is
int value = 192; String specialCharacter = "" + (char)value; System.out.println("special A[" + specialCharacter.charAt(0) + "]");
That's right, the concise answer is "just cast it to a char". I just wanted to make sure you really had Unicode in mind. Many people think that some extended version of ASCII is what Java uses, and they get confused when they don't see the character they expect when they do that.