
html code:
來源:http://www.chinese-learner.com/tools/chinese-converter.php
<!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">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Convert Chinese between Simplifed and Traditional</title>
<meta name="keywords" content="convert chinese simpilfied, traditional chinese 汉字,简体,繁体,简繁体转换,gb2312,big5,转换"/>
<meta name="description" content="convert chinese from simpified chinese to traditional chinese, from traditional to simplified 汉字,简体,繁体,简繁体转换,gb2312,big5,转换"/>
<script type="text/javascript" language="javascript" src="chinese-convert.js"></script>
</head>
<body>
<center>
<textarea id="txt" rows="10" cols="50" value="" name="txt">大家一起学中文,缔友计算机信息技术有限公司,涂聚文, 涂斯博</textarea>
<br/> <input type="button" onclick="convert('s')" value="Convert to Simplified" name="button"/> <input type="button" onclick="convert('t')" value="Convert to Traditional" name="button2"/><input type="hidden" name="h1" value="0"/>
</center>
</body>
</html>javascript code
<!--
//*************Copyright 2003*****************
//This script is written by neweroica, 2003-1-6
//參考:http://www.chinese-learner.com/tools/chinese-converter.php)
//******************************************
function charPYStr(){
return
function ftPYStr(){
return
}
function traditionalized(cc){
var str='';
for(var i=0;i<cc.length;i++){
if(charPYStr().indexOf(cc.charAt(i))!=-1)
str+=ftPYStr().charAt(charPYStr().indexOf(cc.charAt(i)));
else
str+=cc.charAt(i);
}
return str;
}
function simplized(cc){
var str='';
for(var i=0;i<cc.length;i++){
if(ftPYStr().indexOf(cc.charAt(i))!=-1)
str+=charPYStr().charAt(ftPYStr().indexOf(cc.charAt(i)));
else
str+=cc.charAt(i);
}
return str;
}
//s is Convert to Simplified
//t is Convert to Traditional
//sample:convert('s','printerName')
//sample:convert('t','printerName')
function convert(a){
if(a=="s")
document.getElementById('txt').value=simplized(document.getElementById('txt').value);
else
document.getElementById('txt').value=traditionalized(document.getElementById('txt').value);
}
//alert(simplized(prompt('','')))
-->