没有现成的函数,这PC如果是chinese发明的就好了.

解决方案 »

  1.   

    从Chinese决不会发明PC,因为PC太简单也许中国走上另外的科学之路了
      

  2.   


    不愧是最原始的方法:<html><head>
    <meta http-equiv="content-type" content="text/html; charset=gb2312">
    <meta name="author" content="chueh">
    <meta name="keywords" content="软件, 程序设计, 书签, 电子, 电脑, 计算机, 等级考试, 考试, 健身, 钱龙, 读物, 键盘, 自动, 链接, 太极, 气功, 鹊桥, software, program, computer, midi, taijiquan, books, DOS, Windows, ASP, JAVA, javascript">
    <title>全角转半角 - que.126.com</title>
    </head><script language="JavaScript">
    function o2c(fm){
    temp=repl(",",", ",document.replace.source.value)
    temp=repl("。",". ",temp)
    temp=repl("“",' "',temp)
    temp=repl("”",'" ',temp)
    temp=repl("/","/",temp)
    temp=repl("‘","'",temp)
    temp=repl("’","'",temp)
    //temp=repl("、",". ",temp)
    temp=repl("("," (",temp)
    temp=repl(")",") ",temp)
    temp=repl("*","*",temp)
    temp=repl("+","+",temp)
    temp=repl("-","-",temp)
    temp=repl(";","; ",temp)
    temp=repl(":",": ",temp)
    temp=repl("[","[",temp)
    temp=repl("]","]",temp)
    temp=repl("{","{",temp)
    temp=repl("}","}",temp)
    temp=repl("!","! ",temp)
    temp=repl("%","%",temp)
    temp=repl("#","#",temp)
    temp=repl("¥","$",temp)
    temp=repl("…","..",temp)
    temp=repl("—","--",temp)
    temp=repl("=","=",temp)
    temp=repl("·",".",temp)//A:%uFF21 A:%41
    //a:%uFF41 a:%61
    //0:%uFF10 0:%30for(var i=0;i<26;i++){
     temp=repl(unescape("%uff"+hex(33+i)),unescape("%"+hex(65+i)),temp);
     temp=repl(unescape("%uff"+hex(65+i)),unescape("%"+hex(97+i)),temp);
    }
    for(var i=0;i<10;i++)
     temp=repl(unescape("%uff"+hex(16+i)),unescape("%"+hex(48+i)),temp);document.replace.target.value=temp;
    return true;
    }function hex(d){
    h1=Math.round(d/16-0.5)
    h2=d-h1*16
    return ""+d2h(h1)+d2h(h2)
    }function d2h(d){
    if(d>9) h=unescape("%"+(d-10+41))
    else h=""+d
    return h
    }function repl(str1,str2,tmp){
    //str1=fm.replSour.value
    //str2=fm.replTarget.value
    //tmp=document.replace.source.value
    result=""
    fmLen=tmp.length
    if(fmLen=0) {  //无内容
     return '';
    }
    strEnd=tmp.indexOf(str1)
    str1Len=str1.length
    i=0
    while(strEnd>=0){
      i++
      result = result + tmp.substring(0,strEnd)+str2
      tmp=tmp.substring(strEnd+str1Len,tmp.length)
      strEnd=tmp.indexOf(str1)
    }
    result=result+tmp;
    if(document.replace.ul[0].checked) result=result.toLowerCase();
    if(document.replace.ul[1].checked) result=result.toUpperCase();
    return result;
    }
    </script>
    <center>
    <BODY onLoad="replace.source.focus()"><FORM NAME="replace">
    对结果进行:<input type=radio name=ul>大写->小写&nbsp;&nbsp;
    <input type=radio name=ul>小写->大写&nbsp;&nbsp;
    <input type=radio name=ul checked>大小写不转换&nbsp;<input type=reset value=" 清空内容 " onClick="replace.source.focus()"><br>
    <textarea name="source" rows=11 cols=80 onblur="o2c(this.form);return true">
    </textarea><br>
    <textarea name="target" rows=11 cols=80>
    </textarea>
    </FORM></center>
    </BODY></HTML>