function cutstr(str, len) { var temp, icount = 0, patrn = /[^/x00-/xff]/, strre = ""; for (var i = 0; i < str.length; i++) { if (icount < len - 1) { temp = str.substr(i, 1); if (patrn.exec(temp) == null) { icount = icount + 1 } else { icount = icount + 2 } strre += temp } else { break; } } return strre + "..." }
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/8853.html