PDA

Click to See Complete Forum and Search --> : [RESOLVED] Hex conversion problem...


eakin
Jun 1st, 2010, 06:54 AM
Hi I need to convert a hex string in UTF-16 to a hex string in UTF-8

i.e
String input ="0x0630"; //ARABIC LETTER THAL

I want the output to be a hex representation of the same charcter in UTF-8.

Does anyone know the java code to do this?

ComputerJy
Jun 1st, 2010, 08:49 AM
Try this, I have no idea if it's the correct result
final Character c = Character.valueOf((char) (Integer.parseInt("630", 16)));
System.out.println(Integer.toString(Charset.forName("utf-8").newEncoder().encode(CharBuffer.wrap(new char[] { c })).getChar(), 16));

eakin
Jun 1st, 2010, 09:30 AM
Exactly what I was looking for!
Thanks for your help!