标签:blog ar java for sp div log bs amp
/** * 计算字符串的显示长度,半角算1个长度,全角算两个长度 * @param s * @return */ public static int computeDisplayLen( String s ) { int len = 0; if ( s == null ) { return len; } for(int i = 0; i < s.length(); ++i) { char c = s.charAt(i); if(c >= ‘\u0000‘ && c <= ‘\u00FF‘) { len = len + 1; } else { len = len + 2; } } return len; }
标签:blog ar java for sp div log bs amp
原文地址:http://www.cnblogs.com/wzktravel/p/4057105.html