Hello All,
I have been searching the internet for help with a problem..
I have a file that gets sent from a desktop pc to my java mobile device over gprs,
and I need to parse that file to reflect the contents on the screen.
Somehow I am unable to convert the data successfully to unicode representation.
byte[] data1 = {0x4E,0x61,0x76, 0x20, 0x54,(byte) 0xEA, 0x73,0x74}; String[] encoders = {"US-ASCII","ISO-8859-1","UTF-8","UTF-16BE","UTF-16LE","UTF-16"}; int encId = 0; while (encId < encoders.length) { try { System.out.println("Encoding: " + encoders[encId]); String s1 = new String(data1,0,data1.length, encoders[encId]); System.out.println("Name: " + s1); encId ++; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
my output for that code:
Encoding: US-ASCII
Name: Nav T?st
Encoding: ISO-8859-1
Name: Nav T�st
Encoding: UTF-8
Name: Nav T
Encoding: UTF-16BE
Name: ????
Encoding: UTF-16LE
Name: ????
Encoding: UTF-16
Name:
what I need... "Nav Têst" ( I know that's not how you spell "test")
I have also tried the DataInputStream class, but with no luck. Any other ideas?