<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
<head>
<title> 234234324</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="generator" content="editplus" />
<meta name="author" content="eLore" />
<script language="javascript">
function mm(){
if (window.event.keyCode==13){
isOverBytes(document.getElementById("cc").value);
}
}
function isOverBytes(s){
var i = 0;
var bytes = 0;
var uFF61 = parseInt("FF61", 16);
var uFF9F = parseInt("FF9F", 16);
var uFFE8 = parseInt("FFE8", 16);
var uFFEE = parseInt("FFEE", 16);
var j=0;
var m=false;
while (i < s.length)
{
var c = parseInt(s.charCodeAt(i));
if (c < 256) {
bytes = bytes + 1;
}else {
if ((uFF61 <= c) && (c <= uFF9F)) {
bytes = bytes + 1;
}else if ((uFFE8 <= c) && (c <= uFFEE)) {
bytes = bytes + 1;
}else {
bytes = bytes + 2;
}
}
i = i + 1;
}
bytes=bytes%34;
bytes=34-bytes;
if (bytes==0){
return;
}
if (bytes%2==1){
j=(bytes-1)/2;
m=true;
}else{
j=bytes/2;
}
for (i=0;i<j;i++){
document.getElementById("cc").value+="";
}
if (m){
document.getElementById("cc").value+=" ";
}
}
</script>
</head>
<body>
<textarea id="cc" cols="34" οnkeydοwn="mm()"></textarea>
</body>
</html>