Android Arabic Char Count arabicCharCount(String text)

Here you can find the source of arabicCharCount(String text)

Description

arabic Char Count

Declaration

public static double arabicCharCount(String text) 

Method Source Code

//package com.java2s;

public class Main {
    public static double arabicCharCount(String text) {
        double arabicCount = 0;
        double otherCount = 0;

        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);
            if (isArabic(c)) {
                ++arabicCount;/* w w w .j  a  v a  2  s  .c  om*/
            } else if (isLatin(c)) {
            } else {
                ++otherCount;
            }
        }

        return arabicCount > 0 ? arabicCount / (text.length() - otherCount)
                : 0;
    }

    public static boolean isArabic(char c) {
        return (0x0621 <= c && c <= 0x06ED);
    }

    public static boolean isLatin(char c) {
        return (0x41 <= c && c <= 0x5A) || (0x61 <= c && c <= 0x7A);
    }
}