Re: [問題] 關於解碼的問題

看板Programming作者 (godfat 真常)時間17年前 (2007/08/18 18:54), 編輯推噓2(201)
留言3則, 2人參與, 最新討論串3/4 (看更多)
※ 引述《LPH66 (台大我回來了!)》之銘言: : 這是大五碼轉unicode : (其實看到這種五位數就在想會不會是雙字元組編碼 : 不過看到有小於32768的本來以為不是 : 後來突然想到unicode 就抓來試一下馬上試出來了) : 你的八個例子 : Big5: 46958 49241 47954 50502 45258 44233 46679 42673 : 其十六進位: B76E C059 BB52 C546 B0CA ACC9 B657 A6B1 : 對應字: 搖 頭 舞 轟 動 界 超 曲 : unicode: 25622 38957 33310 36703 21205 30028 36229 26354 : 其十六進位: 6416 982D 821E 8F5F 52D5 754C 8D85 66F2 : 這個轉換方法依各平台有異 可以上google去查 我沒碰過編碼,但因為好奇所以稍微試了一下: ruby -e 'puts "\xb7\x6e"' > out.txt 拿給 borwser 看後,確實是個 big5「搖」字 至於 上面所寫的 unicode, 直接輸出似乎不能看, 我猜是 BOM 的關係,所以隨便挑了一個試: ruby -e 'puts "\xfe\xff\x64\x16"' > out.txt 出來果然就是 utf-16 big endian 的「搖」 我有一個額外的小問題,就是我試了很久才發現 \123 其實是 8 進位, 要使用 16 進位不能寫 \0x64, 而要用 \x64... 然後找不到使用 10 進位的方式... 可否請教是否有 10 進位表示法?不知道要怎麼 google, 不能查符號真的有點討厭...試了 \d123 好像沒有用。 謝謝 -- #!/usr/bin/ruby [露比] /Programming (Kn|N)ight/ 看板《Ruby》 # if a dog nailed extra legs that http://www.ptt.cc/bbs/Ruby/index.html # walks like an octopus, and Welcome ~Ruby@ptt~ # talks like an octopus, then ◢█◣ http://www.ruby-lang.org/ # we are happy to treat it as http://www.ruby-doc.org/ # if it were an octopus. http://www.rubyforge.org/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.135.28.18

08/18 22:55, , 1F
傻了嗎,普通打的數字就是10進位數字
08/18 22:55, 1F

08/18 22:56, , 2F
幾乎沒有編碼是以10進位做的,因此沒有
08/18 22:56, 2F

08/19 10:35, , 3F
搖 (utf-8) html entity
08/19 10:35, 3F
文章代碼(AID): #16nj01-B (Programming)
文章代碼(AID): #16nj01-B (Programming)