How can I render percent encoding in command line?

↘锁芯ラ 提交于 2019-12-08 10:24:58

问题


I often have a string "percent encoded", such as %D1%84%D0%B0%D0%B9%D0%BB, which, if it's part of a link, a modern browser would properly render as файл.

I wonder: is there a simple way to "render" a text file with percent encoding (or simply an input string in percent encoding) as the one above by using sed or other command line tool?

See also this related question.


回答1:


Python can do this using urllib.unquote_plus:

#!/usr/bin/env python2

import sys
import urllib

print urllib.unquote_plus("%D1%84%D0%B0%D0%B9%D0%BB")

You can set an alias to have a quick cli command: http://ruslanspivak.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/



来源:https://stackoverflow.com/questions/14078628/how-can-i-render-percent-encoding-in-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!