Java tutorial
//package com.java2s; public class Main { public static int textCounter(String s) { int counter = 0; for (char c : s.toCharArray()) { if (c < 128) { counter++; } else { counter += 2; } } return counter; } }