Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this guys:</p> <pre><code>/** * Utility class to detect arabic languages and convert numbers into arabic digits. * * @author Ahmed Shakil * @date 09-24-2012 */ public final class ArabicUtil { private static final char[] DIGITS = {'\u0660','\u0661','\u0662','\u0663','\u0664','\u0665','\u0666','\u0667','\u0668','\u0669'}; /** * Returns &lt;code&gt;true&lt;/code&gt; if the provided language code uses arabic characters; othersise &lt;code&gt;false&lt;/code&gt;. * @param lang ISO language code. * @return &lt;code&gt;true&lt;/code&gt; if the provided language code uses arabic characters; othersise &lt;code&gt;false&lt;/code&gt; */ public static boolean isArabic (String lang) { return "ar".equals(lang) || "fa".equals(lang) || "ur".equals(lang); } /** * Convert digits in the specified string to arabic digits. */ public static String convertDigits (String str) { if (str == null || str.length() == 0) return str; char[] s = new char[str.length()]; for(int i =0;i&lt;s.length;i++) s[i] = toDigit( str.charAt( i ) ); return new String(s); } /** * Convert single digit in the specified string to arabic digit. */ public static char toDigit (char ch) { int n = Character.getNumericValue( (int)ch ); return n &gt;=0 &amp;&amp; n &lt; 10 ? ARABIC[n] : ch; } /** * Convert an int into arabic string. */ public static String toString (int num) { return convertDigits( Integer.toString( num ) ); } } </code></pre> <p>BTW there is a difference between arabic digits vs. urdu/farsi: Arabic:</p> <pre><code>private static final char[] ARABIC = {'\u0660', '\u0661', '\u0662', '\u0663', '\u0664', '\u0665', '\u0666', '\u0667', '\u0668', '\u0669'}; </code></pre> <p>Urdu or Farsi:</p> <pre><code>private static final char[] URDU_FARSI = {'\u06f0', '\u06f1', '\u06f2', '\u06f3', '\u06f4', '\u06f5', '\u06f6', '\u06f7', '\u06f8', '\u06f9'}; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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