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]
# 1
I'm not exactly sure what you're asking.Are you saying that you want to retrieve the unicode value of the character '5' or you want to display the character that corresponds to unicode 0x05?
Navy_Codera at 2007-7-12 18:28:53 > top of Java-index,Java Essentials,New To Java...
# 2

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

TuringPesta at 2007-7-12 18:28:53 > top of Java-index,Java Essentials,New To Java...
# 3
really thanks.Im not sure about TuringPest's answer, but yes Navy_Corder, im trying to retrieve the unicode value of 5 or any character.bye
Buttonpola at 2007-7-12 18:28:53 > top of Java-index,Java Essentials,New To Java...
# 4

> 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);

}

}

TuringPesta at 2007-7-12 18:28:53 > top of Java-index,Java Essentials,New To Java...
# 5
See Turing_Pest's response.
Navy_Codera at 2007-7-12 18:28:53 > top of Java-index,Java Essentials,New To Java...
# 6
really awsome.you are my idols :)please note that its my first java program (chess program) that I try to make and this is a piece of that.My profesors doesnt knew an answer to me, so you become my new profesorsReally thanksBye
Buttonpola at 2007-7-12 18:28:53 > top of Java-index,Java Essentials,New To Java...
# 7
Hahahaha! No problem. Come back whenever you need help,im sure NavyCoder will like adding Professor to his name.: )
TuringPesta at 2007-7-12 18:28:53 > top of Java-index,Java Essentials,New To Java...
# 8
> 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 ;-)
Navy_Codera at 2007-7-12 18:28:53 > top of Java-index,Java Essentials,New To Java...