html页面之间传参乱码,急求教,在两个htm页面传参数时中文出现了乱码,试了网上的方法不管用。_html/css_WEB-ITnose...
js html java開發 中文亂碼
Dialog = $.ligerDialog.open({url:"plot.htm?examCourse="+examCourse+"examScore="+examScore+"averageScore="+averageScore+"classRank="+classRank, height: 350,width: 450,title:'單科成績詳細分析'});傳到plot.htm頁面后examCourse中文出現了亂碼,因為只有這個是中文,所以只有這個是亂碼,其他的都是對的,用了網上的encodeURIComponentinfo方法后還是不管用,依舊是很多百分號的亂碼,哪位熱心網友幫我解答一下。急急急急急急!
回復討論(解決方案)
%亂碼就是url編碼的結果,服務端解碼一下就行了,肯定有現成的函數
用哪個函數啊,網上查了幾個還是不管用?
%亂碼就是url編碼的結果,服務端解碼一下就行了,肯定有現成的函數 用哪個函數啊,網上查了幾個還是不管用?
Try thisfunction utf8to16(str) { var out, i, len, c; var char2, char3; out = ""; len = str.length; i = 0; while(i < len) { c = str.charCodeAt(i++); switch(c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: out += str.charAt(i-1); break; case 12: case 13: char2 = str.charCodeAt(i++); out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); break; case 14: char2 = str.charCodeAt(i++); char3 = str.charCodeAt(i++); out += String.fromCharCode(((c & 0x0F) << 12) |((char2 & 0x3F) << 6) |((char3 & 0x3F) << 0)); break; } } return out;}document.writeln(utf8to16(unescape("%E4%BD%A0%E5%A5%BD")));
Try thisfunction utf8to16(str) { var out, i, len, c; var char2, char3; out = ""; len = str.length; i = 0; while(i < len) { c = str.charCodeAt(i++); switch(c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: out += str.charAt(i-1); break; case 12: case 13: char2 = str.charCodeAt(i++); out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); break; case 14: char2 = str.charCodeAt(i++); char3 = str.charCodeAt(i++); out += String.fromCharCode(((c & 0x0F) << 12) |((char2 & 0x3F) << 6) |((char3 & 0x3F) << 0)); break; } } return out;}document.writeln(utf8to16(unescape("%E4%BD%A0%E5%A5%BD"))); 我后面一直找一直找,試了很多方法,最后用decodeURI居然奇跡般的好了,呵呵,把分都給你們吧
聲明:本文原創發布php中文網,轉載請注明出處,感謝您的尊重!如有疑問,請聯系admin@php.cn處理
新人創作打卡挑戰賽發博客就能抽獎!定制產品紅包拿不停!總結
以上是生活随笔為你收集整理的html页面之间传参乱码,急求教,在两个htm页面传参数时中文出现了乱码,试了网上的方法不管用。_html/css_WEB-ITnose...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 按文件类型获取其图标
- 下一篇: 当对项目强名时自动构建失败(TeamFo