天ä¸ä¸ããã°ã©ãã¼ã³ã³ãã¹ã
以ä¸ã®æååã¯UTF-8ãæåã¨ã³ã³ã¼ãã£ã³ã°å½¢å¼ã¨ãã16é²æ°ã®ãã¤ãåã§ããã
http://www.klab.jp/tenka1programer/bosyu.html
UTF-8ã§ã¨ã³ã³ã¼ãã£ã³ã°ãããæååã¨ãã¦è§£æããå ´åããã®æååã®ãæåæ°ããçããªããã
ãã®åé¡ããsedãtrãwcã§ãã£ã¦ã¿ãã
$ sed 's/\(.\)./\1/g' <<EOT | tr -d '89ab\n' | wc -c > e4bba5e4b88be381aee69687e5ad97e58897e381af5554462d38e38292e69687e5ad97 > e382a8e383b3e382b3e383bce38387e382a3e383b3e382b0e5bda2e5bc8fe381a8e381 > 99e3828b3136e980b2e695b0e381aee38390e382a4e38388e58897e381a7e38182e3828be38082 > EOT 41
ãã£ã¦ãçãã¯41ã
念ã®ãããä½ãæ¸ãã¦ãã£ãã®ãRuby(1.9)ã§ç¢ºèªã
p [<<EOT.delete("\n")].pack('H*').force_encoding('UTF-8') e4bba5e4b88be381aee69687e5ad97e58897e381af5554462d38e38292e69687e5ad97 e382a8e383b3e382b3e383bce38387e382a3e383b3e382b0e5bda2e5bc8fe381a8e381 99e3828b3136e980b2e695b0e381aee38390e382a4e38388e58897e381a7e38182e3828be38082 EOT
ä¸èº«ã¯ã"以ä¸ã®æååã¯UTF-8ãæåã¨ã³ã³ã¼ãã£ã³ã°å½¢å¼ã¨ãã16é²æ°ã®ãã¤ãåã§ããã" ã ã£ãã
ãã¼ããã
2é²æ° | 16é²æ° | UTF-8ã§ã®æå³ |
---|---|---|
0bbb | 0ã7 | 1ãã¤ãæå |
10bb | 8ãb | 2ã6ãã¤ãæåéå é |
110b | c,d | 2ãã¤ãæåå é |
1110 | e | 3ãã¤ãæåå é |
1111 | f | 4ã6ãã¤ãæåå é |
ä¸ä½4ãããããè¦ã¦ãªãã®ã§5ã6ãã¤ãæåã使ããã¦ããå ´åã¯æ£ããå¦çã§ããªããã¨ã«ãªããã以ä¸ã«ããã¨åé¡ãªãããã
UTF-8 - Wikipedia
http://ja.wikipedia.org/wiki/UTF-8
5ã6ãã¤ã
* Unicodeã®ç¯å²å¤(ã©ããªæåãç»é²ããããã¨ããè¨ç»ãç¡ã)
追è¨
perl ã§æçã£ã½ãæ¸ãæ¹ãããã¨ããããªï¼
perl -pe"$_=s/..([8-b].)*//g"http://d.hatena.ne.jp/miau/20090618/1245353984
ããã¯ãã¾ãã
perlã®sã³ãã³ãã¯ç½®æå¾æååãããªãã¦ç½®ææ°ãè¿ãã®ã§ãä»åã®ãé¡ã«ã¯ãã£ã¦ã¤ãã ã