Print arabic string in java

I am trying to display Arabic text in java, but it shows garbage characters (Example: ¤ [ï߯ [î) or sometimes only question marks when printing. How to do it for print arabic. I heard that this is due to Unicode and UTF-8. This is the first time I work with languages, so I have no idea. I am using the Eclipse Indigo IDE.

EDIT: If I use UTF-8 encoding, then "¤ [ï߯ [î" characters become "????????" characters.

+6
source share
3 answers

To get started, you can look here . This should allow you to make Unicode printable for Eclipse on your console (which I don’t know if this is what Eclipse supports out of the box without any additional configuration)

If this does not solve your problem, you most likely have a problem with the encoding used by your program, so you may need to create lines in some way similar to this:

String str = new String("تعطي يونيكود رقما فريدا لكل حرف".getBytes(), "UTF-8");

That at least works for me.

+7
source

If you insert text literally in code, make sure that you have correctly set the encoding for your project.

+2
source

Is it for Java SE, Java EE or Java ME? If this is for Java ME, you should make custom GlyphUtils if using LWUIT. Download this file: http://dl.dropbox.com/u/55295133/U0600.pdf See a list of Unicode encodings. And look at this topic: fooobar.com/questions/916232 / ... in response (message) to Mohamed Nazar, edited by Bernama Alex Klyuchnikov, "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 \u0628\u06A9 two Arabic letters" Look at the file U0600.pdf so that we can see that Mohamed Nazar and Alex Klyuchnikova give an example so that create the Arabic symbol "ba" and "kaf".

Then the last point you should consider is: "Make sure your user interface supports the unicode (I mean Arabic) character." Like LWUIT, we do not support the unicode (I mean Arabic) character. You must make your own code if you mean that your application uses LWUIT.

+1
source

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


All Articles