How can I render percent encoding in command line?

2019-06-14 09:49发布

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条回答
放荡不羁爱自由
2楼-- · 2019-06-14 10:35

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/

查看更多
登录 后发表回答