Android examples for java.lang:Character
get Byte Count for input string
import android.R; import java.util.regex.Pattern; public class Main{ public static int getByteCnt(String paramString) { if ((paramString == null) || (paramString.length() == 0)) { return 0; }// w ww .ja v a2s . c om int byteCnt = 0; int len = paramString.length(); for (int index = 0; index < len; index++) { int ch = Character.codePointAt(paramString, index); if ((ch >= 0) && (ch <= 255)) { byteCnt += 1; } else { byteCnt += 2; } } return byteCnt; } }