Example usage for java.lang Character codePointAt

List of usage examples for java.lang Character codePointAt

Introduction

In this page you can find the example usage for java.lang Character codePointAt.

Prototype

public static int codePointAt(char[] a, int index) 

Source Link

Document

Returns the code point at the given index of the char array.

Usage

From source file:org.opencron.common.utils.StringUtils.java

/**
 * ?schar//from   ww w .  j  a va 2  s.  c  o  m
 *
 * @param s
 * @return
 */
public static int getWordCount(String s) {
    int length = 0;
    for (int i = 0; i < s.length(); i++) {
        int ascii = Character.codePointAt(s, i);
        if (ascii >= 0 && ascii <= 255)
            length++;
        else
            length += 2;
    }
    return length;
}