Just convert it to int :
char registered = '®'; int code = (int) registered;
There is actually an implicit conversion from char to int , so you do not need to specify it explicitly, as I did above, but I would do it in this case so that it is obvious what you are trying to do.
This will give a UTF-16 code that matches the Unicode code point for any character defined on the base multilingual plane. (And only BMP characters can be represented as char values in Java.) As Andrzej Doyle says, if you want Unicode code from an arbitrary string, use Character.codePointAt() .
Once you get the UTF-16 code code or Unicode code codes, but of which are integers, it is up to you what you do with them. If you need a string representation, you need to determine exactly which representation you want. (For example, if you know that the value will always be in BMP, you may need a fixed four-digit hexadecimal representation with the prefix U+ , for example, "U+0020" for a space.) However, this is beyond the scope of this question, since we do not know what the requirements are .
Jon Skeet Jan 05 '10 at 14:20 2010-01-05 14:20
source share