vbscript版的统计中英文都可以的,英文为1个字符,中文为2个字符,在网上找得太辛苦了,百度基本找不到,google的找到了,却老是无法显示此页,日你他妈的paty
javascript:
function countsl(val) {
var sum=0; if(val){ for(var i=0;i<val.length;i++){ if(val.charCodeAt(i)>255){sum+=2;} else{sum+=1;} } } return sum;}
vbscript:
Function ChineseLen(Str)
Dim oRegExp, sTmp If Len(Trim(str)) > 0 Then Set oRegExp = new RegExp oRegExp.IgnoreCase = True oRegExp.Global = True oRegExp.Pattern = "[\uff00-\uffff\u4e00-\u9fa5\ufe10-\ufe1f\ufe30-\ufe4f\u1100-\u11ff\u2600-\u26ff\u2700-\u27bf\u2800-\u28ff\u3300-\u33ff\u3200-\u32ff\ua490-\ua4cf\ua000-\ua48f\u3130-\u318f\uac00-\ud7af\u31f0-\u31ff\u30a0-\u30ff\u3040-\u309f\u31a0-\u31bf\u3100-\u312F\u2FF0-\u2FFF\u2F00-\u2FDF\u31c0-\u31ef\u3000-\u303f\u2e80-\u2eff\uff00-\uffef]" sTmp = oRegExp.Replace(str, "xx") Set oRegExp=Nothing End If ChineseLen = Len(sTmp) End function posted on 2013-11-15 21:25 阅读( ...) 评论( ...)