分页: 1 / 1

Shell中[如何将中文URL编码]

发表于 : 2008-11-29 19:10
lifelse
如题 Shell中[如何将中文URL编码]

类似于

代码: 全选

%5B%E7%94%B5%E5%BD%B1%E5%A4%A9%E5%A0%82

Re: Shell中[如何将中文URL编码]

发表于 : 2008-12-01 18:47
c\nc
echo -n 汉字 | od -xAn

字节序问题就自己搞吧 :em04

Re: Shell中[如何将中文URL编码]

发表于 : 2008-12-01 19:28
xhy
php: urlencode
python: urllib.quote

Re: Shell中[如何将中文URL编码]

发表于 : 2008-12-01 20:57
lifelse
呵呵。谢谢各位啊!
明天试试看!

Re: Shell中[如何将中文URL编码]

发表于 : 2008-12-01 21:10
xiooli
1, urlencode
echo -n "汉字语句" | od -t x1 -A n -w1000|tr " " "%"
2, urldecode
perl -p -e 's/%(..)/pack("c", hex($1))/eg'

Re: Shell中[如何将中文URL编码]

发表于 : 2008-12-03 10:49
lifelse
xiooli 的答案最简单了。谢谢。
当然其他两文的回复也是正确的经过验证!

Re: Shell中[如何将中文URL编码]

发表于 : 2008-12-03 10:59
eexpress
perl的。我早发过的。处理字符,当然是perl了。