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:
posted 10 years ago
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".
posted 10 years ago
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.
Paper jam tastes about as you would expect. Try some on this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java