Display Arabic Text in J2me Using Eclipse

I'm new to J2me, could someone kindly tell me how can I do below in J2me? A.

String salam="ุงูŽู„ู„ู‘ูฐู‡ูู…ูŽู‘ ุงูู†ูู‘ู‰ู’ ุงูŽุณู’ุฆูŽู„ููƒูŽ ุฑูุฒู’ู‚ู‹ุงูˆูŽู‘ุงุณูุนู‹ุงุทูŽูŠูู‘ุจู‹ุงู…ูู†ู’ ุฑูุฒู’ู‚ููƒูŽ"; byte[] bytes = salam.getBytes("UTF-8"); str1=new String(bytes); System.out.println("Arabic :"+str1); 

it displays "ร˜" "ร˜ยง" ... char like this

I am using Eclipse Indigo Service Release 1.

+3
source share
3 answers

The code below can be used to display Arabic text in J2ME

 String s=new String("\u0628\u06A9".getBytes(), "UTF-8"); 

where \u0628\u06A9 is the unicode of two Arabic letters

+1
source

You should use the String constructor, which allows you to specify an encoding with an argument of type String(byte[], Charset) (No Charset in J2ME) or String(byte[], String) . Otherwise, the byte array will be decoded using the default platform, which may not be UTF-8.

Example:

  byte[] utf8bytes = ... //Byte array containing UTF-8 as bytes. String string = new String(utf8bytes, "UTF-8"); 
+2
source

I found a solution:
Window > Preferences > General > Content Types

Select the type of file you want (Text => java in your case)

Now insert UTF-8 into the default encoding and click "Update".

-1
source

Source: https://habr.com/ru/post/916232/


All Articles