Questions tagged [urlencode]

To “URL encode” or “percent encode” text means to encode it for use in a URL. Some characters are not valid when used as-is in URLs, and so much be URL-encoded (percent-encoded) when appearing in URLs.

https://url.spec.whatwg.org/#percent-encoded-bytes is the section of the current URL standard that defines percent encoding (URL encoding).

2314 questions
49
votes
8 answers

urllib.urlencode doesn't like unicode values: how about this workaround?

If I have an object like: d = {'a':1, 'en': 'hello'} ...then I can pass it to urllib.urlencode, no problem: percent_escaped = urlencode(d) print percent_escaped But if I try to pass an object with a value of type unicode, game over: d2 = {'a':1,…
user18015
47
votes
4 answers

cannot urllib.urlencode a URL in python

Why am I getting this error when trying to urlencode this string >>> callback = "http://localhost/application/authtwitter?twitterCallback" >>> urllib.urlencode(callback) Traceback (most recent call last): File "", line 1, in…
BillPull
  • 6,853
  • 15
  • 60
  • 99
42
votes
3 answers

urllib.quote() throws KeyError

To encode the URI, I used urllib.quote("schönefeld") but when some non-ascii characters exists in string, it thorws KeyError: u'\xe9' Code: return ''.join(map(quoter, s)) My input strings are köln, brønshøj, schönefeld etc. When I tried just…
Garfield
  • 2,487
  • 4
  • 31
  • 54
41
votes
6 answers

How to know if a URL is decoded/encoded?

I am using Javascript method decodeURIComponent to decode an encoded URL. Now I am having an issue, that sometimes the URL is get encoded twice during redirection between servers, sometimes it is encoded only once. I want to check that if the URL…
Tapas Bose
  • 28,796
  • 74
  • 215
  • 331
40
votes
2 answers

Pass a percent (%) sign in a url and get exact value of it using php

I am trying to pass percent (%) sign in url like %B6011000995504101^SB but when I echo, it returns ♦011000995504101^SB I want exact same value as I pass it in URL. I have tried to use urlencode() function, but it give me output like…
Sumit Bijvani
  • 8,154
  • 17
  • 50
  • 82
39
votes
4 answers

Why is the comma URL encoded?

When debugging in ASP.NET MVC, I don't see a difference between: http://mysite.com?q=hi,bye and http://mysite.com?q=hi%2Cbye The querystring param "q" always has a value of "hi,bye". So why is the comma encoded? I want to do something like this…
Scott Coates
  • 2,462
  • 5
  • 31
  • 40
37
votes
3 answers

Best way to get query string from a URL in python?

I need to get the query string from this URL https://stackoverflow.com/questions/ask?next=1&value=3 and I don't want to use request.META. I have figured out that there are two more ways to get the query string: Using…
NIlesh Sharma
  • 5,445
  • 6
  • 36
  • 53
36
votes
2 answers

How to URL encode periods?

I need to URL encode some periods since I have to pass some document path along and it is like this http://example.com/test.aspx?document=test.docx So test.docx is causing me an error of an illegal character. So I need to change it to . --> …
chobo2
  • 83,322
  • 195
  • 530
  • 832
36
votes
5 answers

Encoding of XHTML and & (ampersand)

My website is XHTML Transitional compliant except for one thing: the & (ampersand) in the URL are written as it is, instead of & That is, all the URLs in my pages are usually like this:
Robert
35
votes
7 answers

how to insert %20 in place of space in android

I have a xml URL file in which there are white spaces i want to replace white spaces with %20.. how to do this???? SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); /** Send…
SRam
  • 2,832
  • 4
  • 45
  • 72
35
votes
1 answer

Using mod_rewrite to convert paths with hash characters into query strings

I have a PHP project where I need to send a hash character (#) within the path of a URL. (http://www.example.com/parameter#23/parameter#67/index.php) I thought that urlencode would allow that, converting the hash to %23 But now I see that even the…
Mark
  • 1,129
  • 2
  • 12
  • 25
34
votes
2 answers

URI encoding in Python Requests package

I am using python requests package to get results from a API and the URL contains + sign in it. but when I use requests.get, the request is failing as the API is not able to understand + sign. how ever if I replace + sign with %2B (URI Encoding) the…
user3435964
  • 663
  • 1
  • 11
  • 23
32
votes
4 answers

Is there a package to marshal in and out of x-www-form-urlencoding in golang

I would like to marshal in and out of x-www-form-urlencoding similar to how you can do it with json or xml. Is there an existing package to do this, or are there any documents on how to implement one myself if none exist?
placeybordeaux
  • 2,138
  • 1
  • 20
  • 42
32
votes
7 answers

HttpUtility.UrlEncode in console application

I'd like to use HttpUtility.UrlEncode in a console application, VB.NET, VS 2010 Beta 2. System.Web.HttpUtility.UrlEncode(item) Error message: 'HttpUtility' is not a member of 'Web'. In this question Anjisan suggests to add a reference to…
George
  • 1,111
  • 3
  • 20
  • 38
32
votes
1 answer

Create url without request execution

I am currently using the python requests package to make JSON requests. Unfortunately, the service which I need to query has a daily maximum request limit. Right know, I cache the executed request urls, so in case I come go beyond this limit, I…
Andy
  • 9,483
  • 12
  • 38
  • 39