close
function calculate(str,limit) {

String.prototype.lenB = function () { return this.replace(/[^\x00-\xff]/g, "**").length; }

if (str.lenB() > limit)

return false;

else

return true;

}








function
calculate(){
String.prototype.lenB =function(){returnthis.replace(/[^\x00-\xff]/g,"**").length;}
//var str = "這是一個可以將漢字計算成兩個位元組的函數";
var str =document.all.uInput.value
alert("老的演算法 = "+ str.length);
alert("新的演算法 = "+ str.lenB());
}


http://codex.wiki/post/191280-944
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 amychang2014 的頭像
    amychang2014

    工作需要筆記

    amychang2014 發表在 痞客邦 留言(0) 人氣()