Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static int getStringLen(String SrcStr) { int return_value = 0; if (SrcStr != null) { char[] theChars = SrcStr.toCharArray(); for (int i = 0; i < theChars.length; i++) { return_value += (theChars[i] <= 255) ? 1 : 2; } } return return_value; } }