<script> (str, len, hasDot) <br>{ <br>var newLength = 0; <br>var newStr = "" <br>var chineseRegex = /[^x00-xff]/g; ""; var <br>var strLength = str.replace(chineseRegex,"**").length; <br>for(var i = 0;i < strLength;i ){ <BR>singleChar = str.charAt( i).toString(); <BR>if(singleChar.match(chineseRegex) != null){ <BR>newLength = 2; <BR>if( newLength > len){ <BR>break; <BR>} <BR><BR>if(hasDot && strLength > len){ <BR>newStr = ".. ."; <BR>} <BR>return newStr; <BR>} <BR>alert(subString("js は文字化けせずに中国語と英語の文字列をインターセプトします",10,true)); <br></script>