Converting char value to unicode
Hi!!
I need some help with a problem. I want to conver a char value to unicode value.
for example I want to display unicode value of number 5
char num=5;
System.out.println(method.ChartoUnicode(num));
please, HELP ME, Im a newbie
thanks all.
Message was edited by:
Buttonpol
[337 byte] By [
Buttonpola] at [2007-11-27 6:54:02]

Unless im missing something...
The Char values IS the Unicode value.
Thats exactly why a Char in Java is 16 bits.
You may need to ensure that you are in the proper encoding.
http://mindprod.com/jgloss/encoding.html
char
2 bytes, unsigned, Unicode, 0 to 65,535
http://www.cafeaulait.org/course/week2/02.html
> Im not sure about TuringPest's answer,
Wow. That was rather flippant.
import java.nio.charset.Charset;
public class CharUnicode{
public static void main(String[] args){
char letter = 'k';
System.out.println("Unicode Value: " + (int)letter);
String fileEncoding = System.getProperty("file.encoding");
String charEncoding = Charset.defaultCharset().name();
System.out.println("File Encoding: " + fileEncoding);
System.out.println("Char Encoding: " + charEncoding);
}
}
> Hahahaha! No problem. > Come back whenever you need help,> im sure NavyCoder will like adding Professor to his> name.> : )That is one title I have never wanted for myself. Thanks, though ;-)