I am new to J2me, kindly can anybody tell me how can I do below in J2me?
String salam="اَللّٰهُمَّ اِنِّىْ اَسْئَلُكَ رِزْقًاوَّاسِعًاطَيِّبًامِنْ رِزْقِكَ";
byte[] bytes = salam.getBytes("UTF-8");
str1=new String(bytes);
System.out.println("Arabic :"+str1);
it is displaying سلام char like that
I am using Eclipse Indigo Service Release 1.
You should use the a String contructor that allows you to specify the charset with an argument like (No String(byte[], Charset)Charset in J2ME) or String(byte[], String). Otherwise the byte array will be decoded using the platform default which may not be UTF-8.
Example:
byte[] utf8bytes = ... //Byte array containing UTF-8 as bytes.
String string = new String(utf8bytes, "UTF-8");
The below code can be use for displaying arabic text in J2ME
String s=new String("\u0628\u06A9".getBytes(), "UTF-8");
where \u0628\u06A9 is the unicode of two arabic letters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With