1、原生JavaScript实现字符串长度截取
1 function cutstr(str, len) { 2 var temp; 3 var icount = 0; 4 var patrn = /[^\x00-\xff]/; 5 var strre = ""; 6 for (var i = 0; i < str.length; i++) { 7 if (icount < len - 1) { 8 temp = str.substr(i, 1); 9 if (patrn.exec(temp) == null) { 10 icount = icount + 1 11 }