Java tutorial
//package com.java2s; public class Main { public static int getStrLength(String content) { int length = 0; int tempLength = 0; for (int i = 0; i < content.length(); i++) { String temp = content.charAt(i) + ""; if (temp.getBytes().length == 3) { length++; } else { tempLength++; } } length += tempLength / 2 + ((tempLength % 2) == 0 ? 0 : 1); return length; } }