全角半角字符串长度获取方法

1、正则表达式方法:

System.Text.RegularExpressions.Regex.Replace(str, "[^\x00-\xff]", "**").Length

2、Encoding方法:

Encoding.Default.GetByteCount(str)

posted @ 2013-01-03 14:03  kylin.chen  阅读(285)  评论(0编辑  收藏  举报