Last active
October 19, 2018 20:21
-
-
Save facugon/c4c16b1c5ed21345eec3e2eb1dfb0044 to your computer and use it in GitHub Desktop.
URL Encode Alternatives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title="something horrible!" | |
encodedtitle=`echo "$title" | jq -s -R -r @uri` | |
# need to install URI::Escape | |
#perl -MURI::Escape -e 1 | |
#if [ $? != 0 ]; | |
#then | |
# echo "installing dependencies" | |
# PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'install URI::Escape' | |
#fi | |
encodedtitle=`perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$title"` | |
encodedtitle=`python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])" $title` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to encode a value that will be used in a URL , for example
http://domain/resouce/to/fetch/with/title/$title
when title is a horrible thing