Android Char Value Check getCharsLength(char[] chars, int specialCharsLength)

Here you can find the source of getCharsLength(char[] chars, int specialCharsLength)

Description

get Chars Length

License

Open Source License

Declaration

private static int getCharsLength(char[] chars, int specialCharsLength) 

Method Source Code

//package com.java2s;

public class Main {

    private static int getCharsLength(char[] chars, int specialCharsLength) {
        int count = 0;
        int normalCharsLength = 0;
        for (int i = 0; i < chars.length; i++) {
            int specialCharLength = getSpecialCharLength(chars[i]);
            if (count <= specialCharsLength - specialCharLength) {
                count += specialCharLength;
                normalCharsLength++;/* w  w w  .  j ava2  s  .  co  m*/
            } else {
                break;
            }
        }
        return normalCharsLength;
    }

    private static int getSpecialCharLength(char c) {
        if (isLetter(c)) {
            return 1;
        } else {
            return 2;
        }
    }

    public static boolean isLetter(char c) {
        int k = 0x80;
        return c / k == 0 ? true : false;
    }
}

Related

  1. isOctal(char c)
  2. isWordSeparator(char c)
  3. isKana(char character)
  4. isWordSeparator(char c, char[] wordSeparators)
  5. getSpecialCharLength(char c)
  6. getNthIndexOf(char c, String str, int n)
  7. displayWidth(char ch)
  8. getCharType(char c)
  9. isAlef(char c)