欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP中如何判斷一個(gè)字符是不是漢字

 更新時(shí)間:2007年03月10日 00:00:00   作者:  
程序設(shè)計(jì)中我們時(shí)常需要檢測(cè)用戶輸入是否正確,特別是姓名,地址等等是不是輸入的漢字。那么,如何判斷一個(gè)字符是不是漢字呢?其實(shí)在asp中至少有兩種方式 
一、直接將某字符用asc轉(zhuǎn)為ascii碼,如果是英文,他應(yīng)該是0-127的范圍,而漢字則是一個(gè)比較大的數(shù)字,所以可以使用以下代碼來判斷: 
if abs(asc(whichchar))>127 then 
response.write whichchar & "是一個(gè)漢字" 
else 
response.write whichchar & "不是一個(gè)漢字" 
end if 
二、漢字的unicode編碼范圍是4e00-9fa5,所以使用正則表達(dá)試就可以判斷一個(gè)漢字是不是漢字了。 
set regexpobj=new regexp 
regexpobj.pattern="^[\u4e00-\u9fa5]+$" 
regcheck=regexpobj.test(whichchar) 
set regexpobj=nothing 
if regcheck then 
response.write whichchar & "是漢字" 
else 
resposne.write whichchar & "不是漢字" 
end if

相關(guān)文章

最新評(píng)論