Here you can find the source of asciiLength(String str)
public static int asciiLength(String str)
//package com.java2s; //License from project: Apache License public class Main { public static int asciiLength(String str) { int length = 0; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); length += c > 127 ? 2 : 1; }//from w ww . j av a 2s. co m return length; } }