帮助以前的前端实现了这个native2ascii功能。
<html>
<head>
<title>native2ascii</title>
<script language="javascript">
function native2ascii(){
regexp = /[^\x00-\xff]/g;
n = document.getElementById( 'native' ).value;
a = n;
while (m = regexp.exec(n)) {
a = a.split(m[ 0 ]).join(escape(m[ 0 ]).split( '%' ).join( '\\\\' ));
}
document.getElementById( 'ascii' ).value = a;
}
function ascii2native() {
// regexp = /[^\x00-\xff]/g;
a = document.getElementById( 'ascii' ).value;
n = a;
n = unescape(n.split( '\\' ).join( '%' ));
n = n.replace(/%/g, '');
document.getElementById('native').value = n;
}
</script>
</head>
<body>
<textarea id ="native" rows ="10" cols ="100"></textarea >
<p/>
<input type ="button" id ="convert" value="convert" οnclick="native2ascii()" />
<input type ="button" id ="back" value ="back" onclick ="ascii2native()" />
<p/>
<textarea id ="ascii" rows ="10" cols ="100"></textarea >
</body>
</html>
这只是一个模板,可以修改一下,直接应用到前端代码中。