Here you can find the source of lengthUnicode(String s)
public static int lengthUnicode(String s)
//package com.java2s; public class Main { public static int lengthUnicode(String s) { if (s == null || s.length() == 0) return 0; int len = 0; for (int i = 0; i < s.length(); i++) { if ((int) s.charAt(i) > 127) len += 2;/*from ww w .j a v a 2 s.co m*/ else len += 1; } return len; } public static int length(String s) { if (s == null || s.length() == 0) return 0; return s.length(); } }