问题
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