亂碼轉(zhuǎn)碼問(wèn)題

          convert(username, "ISO8850-1","GBK")
          convert(username, 
          "ISO8850-1","ISO8850-1")
          public static String convert(String src, String decoding, String encoding) {
                  
          if(src == null || decoding == null || encoding == null)
                      
          return null;

                  
          if(decoding.equals(encoding))
                      
          return src;

                  String rs 
          = null;
                  
          try {
                      
          byte[] tb = src.getBytes(decoding);
                      rs 
          = new String(tb, 0, tb.length, encoding);
                  }
           catch (UnsupportedEncodingException e) {
                      rs 
          = src;
                  }


                  
          return rs;
          或者:String username 
          =new String(request.getParameter("username").getBytes("iso8859-1"),"gbk");

          posted on 2012-10-11 14:53 youngturk 閱讀(416) 評(píng)論(0)  編輯  收藏 所屬分類: JSP隨筆Java基礎(chǔ)

          <2012年10月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          導(dǎo)航

          統(tǒng)計(jì)

          公告

          this year :
          1 jQuery
          2 freemarker
          3 框架結(jié)構(gòu)
          4 口語(yǔ)英語(yǔ)

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊(cè)

          EJB學(xué)習(xí)

          Flex學(xué)習(xí)

          learn English

          oracle

          spring MVC web service

          SQL

          Struts

          生活保健

          解析文件

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 阳春市| 宜昌市| 清河县| 锡林郭勒盟| 太白县| 新泰市| 斗六市| 托里县| 临颍县| 临沧市| 长治县| 四川省| 吴堡县| 江源县| 西昌市| 陇西县| 盈江县| 稻城县| 双峰县| 衡南县| 邵阳县| 明光市| 巴彦淖尔市| 郸城县| 庐江县| 门源| 安丘市| 高阳县| 米泉市| 开封市| 杭锦旗| 岫岩| 梅州市| 连云港市| 溧阳市| 峨眉山市| 晋州市| 崇明县| 潜江市| 托克逊县| 鄂伦春自治旗|