Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am a persian developer and I had the same problem in about 4 years ago.You have some way to solve this problem:<br> 1-using <strong>custom fonts</strong>.<br> 2-<strong>reshape</strong> your text before display it.<br> A good article in about first,is "<a href="http://developers.sun.com/mobility/midp/articles/termemulator3/" rel="nofollow"><strong><em>MIDP Terminal Emulation, Part 3: Custom Fonts for MIDP</em></strong></a> ".But for arabic letters I think that is not simple. In about second way,say you would to replace any character in your text with correct character.This means when you have: </p> <pre><code>String str = "به"; </code></pre> <p>If get str characters they will be look like:<br> {1576,1607} that is like "ب ه" instead of "به".So you would to replace incorrect Unicode with correct Unicode codes(in this case correct characters are: {65169, 65258}).You can use "Arabic Reshapers" even reshapers that designed for android!I saw 2 link for this reshapers:1-<a href="https://github.com/agawish/Better-Arabic-Reshaper" rel="nofollow"><strong><em>github</em></strong></a> 2-<a href="https://sites.google.com/a/ut.utm.edu/arabic-android/" rel="nofollow"><strong><em>Arabic Android</em></strong></a>(I'm persian developer and so I do not try them,instead I create classes with the same idea as they have).<br> <strong>With using a good reshaper also you may have problem with character arranging</strong> from left to right instead of right to left.(some phones draw characters from left to right and other from right to left).I use below class to detect that ordering is true(from right to left) or not: </p> <pre><code>public class DetectOrdering{ public static boolean hasTrueOrdering() { boolean b = false; try { char[] chArr = {65169, 65258}; String str = new String(chArr); System.out.println(str); int width = f1.charWidth(chArr[1]) / 2; int height = f1.getHeight(); image1 = Image.createImage(width, height); image2 = Image.createImage(width, height); Graphics g1 = image1.getGraphics(); Graphics g2 = image2.getGraphics(); g1.drawString(str, 0, 0, 0); g2.drawChar(chArr[1], 0, 0, 0); int[] im1 = new int[width * height]; int[] im2 = new int[width * height]; image1.getRGB(im1, 0, width, 0, 0, width, height); image2.getRGB(im2, 0, width, 0, 0, width, height); if (areEqualIntArrrays(im1, im2)) { b = true; } else { b = false; } } catch (Exception e) { e.printStackTrace(); } return b; } private static boolean areEqualIntArrrays(int[] i1, int[] i2) { if (i1.length != i2.length) { return false; } else { for (int i = 0; i &lt; i1.length; i++) { if (i1[i] != i2[i]) { return false; } } } return true; } } </code></pre> <p>If DetectOrdering.hasTrueOrdering() returns true,sure that phone draw Arabic characters from right to left and display your String.If returns false it draws from left to right.If phone draws Arabic character from left to right you would to reverse string after reshape it and then you can display it. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload