关键代码如下:
class="code_img_closed" src="/Upload/Images/2014040302/0015B68B3C38AA5B.gif" alt="" />logs_code_hide('d8578f06-16a7-4ae2-9da4-e9190ae6f038',event)" src="/Upload/Images/2014040302/2B1B950FA3DF188F.gif" alt="" />/// <summary> /// 估算中英文字符串的宽度 /// </summary> /// <returns></returns> public static double GetWidthUnitCount(string value) { double count = 0; for (var i = 0; i < value.Length; i++) { if (IsChinese(value[i].ToString()) == true) { count += 2; } else if (IsUpChar(value[i].ToString()) == true) { count += 1.5; } else { count += 1; } } return count; } /// <summary> /// 是否汉字或中文标点 /// </summary> private static bool IsChinese(string value) { Regex reg = new Regex("[\u4E00-\u9FFF]|[\uFE30-\uFFA0]"); return reg.IsMatch(value); } /// <summary> /// 是否大写字母 /// </summary> private static bool IsUpChar(string value) { Regex reg = new Regex("[A-Z]"); return reg.IsMatch(value); }View Code