看板 Ajax 關於我們 聯絡資訊
※ 引述《TonyQ (骨頭)》之銘言:
ayuiop:請問為何需要parseInt(escape(valueObj[i]).length) 04/05 13:31
ayuiop:而不直接取用length就好? 04/05 13:32
主要是針對於中文字上的處理,escape後會改變文章長度, 底下這段code應該可以敘述一些事情。 function go(){ var word="哈囉"; msg(word + "_" +word.length); msg(escape(word)+"_"+escape(word).length); } function msg(str){ document.getElementById('msg').innerHTML+="<br />"+str; } 這是執行結果 哈囉_2 %u54C8%u56C9_12 -- String temp="relax"; | Life just like programing while(buringlife) String.forgot(temp); | to be right or wrong while(sleeping) brain.setMemoryOut(); | need not to say stack.push(life.running); | the compiler will stack.push(scouting.buck()); | answer your life stack.push(bowling.practice()); | Bone everything -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.134.27.68
ayuiop:抱歉我沒講清楚,我的意思是為什麼需要parseInt? 04/06 13:58
TonyQ:哦 那個不用理它 ̄▽ ̄ 我只是怕發生 1+1 = 11的慘案而已 04/06 18:55
ayuiop:喔喔XD 04/06 21:59