asp截取中英文字符

function strLeft(str,num)
dim p_str,p_num
    p_str = ""
    p_num = 0   
           
if trim(str) <> "" then
    p_len = len(str)
    for i = 1 to p_len
        if asc(mid(str,i,1)) > 255 or asc(mid(str,i,1)) < 0 then
            p_num = p_num + 2
        else
            p_num = p_num + 1
        end if
       
        if p_num > num then
            p_str = Left(str,i-1) 
            exit for
        else
            p_str = str
        end if
    next
end if

strLeft=p_str
end functio 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章