小剛

          在用struts等編程時,中文轉換成資源文件unicode碼時的一個小程序

          把以下代碼保存成xxx.htm文件即可。
           1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
           2
           3<html>
           4<head>
           5<STYLE><!--
           6.button {
           7    font-size: 10.5pt; 
           8    color: #FFFFFF;
           9    background-color: #F58541;
          10    border: 1px solid #BE5414;
          11    clear: both;
          12    height: 18px;
          13    width: 45px;
          14}

          15.button1 {
          16    font-size: 10.5pt; 
          17    color: #FFFFFF;
          18    background-color: #F58541;
          19    border: 1px solid #BE5414;
          20    clear: both;
          21    height: 18px;
          22    width: 135px;
          23}

          24-->
          </STYLE>
          25    <title>轉換編碼</title>
          26<script language="JavaScript" type="text/javascript" >
          27 function change(){
          28 var onestring=document.form1(0).value;
          29 if(onestring !=""){
          30            var temp=escape(onestring);
          31            var temp1=temp.replace(/\%/g,"\\")
          32            document.form1(5).value=temp1
          33 }
          else{
          34  alert("you must be forgetful,please fill in the blank!")
          35 }

          36}

          37function reversechange(){
          38 var onestring=document.form1(0).value;
          39 if(onestring !=""){
          40            var temp=onestring.replace(/\\/g,"%");
          41            var temp1=unescape(temp);
          42            document.form1(5).value=temp1;
          43
          44 }
          else{
          45  alert("you must be forgetful,please fill in the blank!")
          46 }

          47}

          48function copyresult(){
          49        var e=document.getElementById("result"); 
          50        if(e.value==""){
          51        window.clipboardData.setData("Text","告訴你個秘密,其實剛才什么也沒復制上,哈哈哈哈,傻了吧!");
          52          return;
          53        }

          54        e.select(); 
          55        document.execCommand("Copy"); 
          56    }
           
          57
          </script>    
          58</head>
          59<body>
          60<form name="form1">
          61 請您輸入字符串: <input name="inputstring" type="text" size="100%" >&nbsp;&nbsp;<br><br><br>
          62                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          63                  <input type="button" ONCLICK="change()" value="正向" class="button">  &nbsp;&nbsp;
          64                  <input type="button" ONCLICK="reversechange()" value="反向"  class="button"> &nbsp;&nbsp;
          65                  <input type="reset" onClick="clear"value="clear" class="button">&nbsp;&nbsp;
          66                  <input type="button" onClick="copyresult();"value="點擊復制轉換結果" class="button1"><br><br><br>
          67                  轉換結果:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text"  value="" name="result" size="100%" readonly>
          68
          69</form>
          70</body>
          71</html>
          72

          posted on 2007-08-30 16:52 peter2008 閱讀(1009) 評論(4)  編輯  收藏

          評論

          # re: 在用struts等編程時,中文轉換成資源文件unicode碼時的一個小程序 2007-08-30 17:27 JAVA面試題

          小弟剛接觸Java,瘋狂學習中。。。  回復  更多評論   

          # re: 在用struts等編程時,中文轉換成資源文件unicode碼時的一個小程序 2007-08-30 17:32 久城

          用JS實現的?我JS盲??雌饋硗τ幸馑?。

          也可以寫成一個批處理文件。
          native2ascii a.properties b.properties  回復  更多評論   

          # re: 在用struts等編程時,中文轉換成資源文件unicode碼時的一個小程序 2007-08-30 23:23 popoer

          推薦一個eclipse的插件,可多語言同時編輯,自動保存成unicode編碼
          http://www.guh-software.de/jinto_en.html  回復  更多評論   

          # re: 在用struts等編程時,中文轉換成資源文件unicode碼時的一個小程序 2008-04-17 10:54 songxh

          真的很感謝啊  回復  更多評論   


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 彭山县| 资兴市| 饶平县| 定陶县| 房产| 万州区| 唐河县| 高碑店市| 霍邱县| 镇安县| 三河市| 高雄市| 黄石市| 敦煌市| 阜康市| 新营市| 武威市| 且末县| 江川县| 方山县| 滨州市| 阳江市| 竹山县| 青川县| 万源市| 慈溪市| 五家渠市| 江北区| 庐江县| 阿瓦提县| 偃师市| 芮城县| 哈巴河县| 将乐县| 民和| 聂荣县| 右玉县| 通许县| 武鸣县| 萨迦县| 叶城县|