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
2860
votes
22 answers

Encode URL in JavaScript

How do you safely encode a URL using JavaScript such that it can be put into a GET string? var myUrl = "http://example.com/index.html?param=1&anotherParam=2"; var myOtherUrl = "http://example.com/index.html?url=" + myUrl; I assume that you need to…
nickf
  • 537,072
  • 198
  • 649
  • 721
823
votes
11 answers

Java URL encoding of query string parameters

Say I have a URL http://example.com/query?q= and I have a query entered by the user such as: random word £500 bank $ I want the result to be a properly encoded URL: http://example.com/query?q=random%20word%20%A3500%20bank%20%24 What's the best…
user1277546
  • 8,652
  • 3
  • 17
  • 25
749
votes
15 answers

How to urlencode a querystring in Python?

I am trying to urlencode this string before I submit. queryString = 'eventName=' + evt.fields["eventName"] + '&' + 'eventDescription=' + evt.fields["eventDescription"];
James
  • 9,694
  • 5
  • 32
  • 38
713
votes
48 answers

Query-string encoding of a JavaScript object

Is there a fast and simple way to encode a JavaScript object into a string that I can pass via a GET request? No jQuery, no other frameworks—just plain JavaScript :)
napolux
  • 15,574
  • 9
  • 51
  • 70
601
votes
5 answers

When should space be encoded to plus (+) or %20?

Sometimes the spaces get URL encoded to the + sign, and some other times to %20. What is the difference and why should this happen?
Muhammad Hewedy
  • 29,102
  • 44
  • 127
  • 219
572
votes
8 answers

What is %2C in a URL?

In a URL, what does the %2C encoding mean and what are its uses?
sameold
  • 18,400
  • 21
  • 63
  • 87
515
votes
37 answers

How to urlencode data for curl command?

I am trying to write a bash script for testing that takes a parameter and sends it through curl to web site. I need to url encode the value to make sure that special characters are processed properly. What is the best way to do this? Here is my…
Aaron
  • 19,151
  • 4
  • 28
  • 23
456
votes
14 answers

URL Encoding using C#

I have an application which sends a POST request to the VB forum software and logs someone in (without setting cookies or anything). Once the user is logged in I create a variable that creates a path on their local…
masfenix
  • 7,736
  • 11
  • 45
  • 60
419
votes
11 answers

urlencode vs rawurlencode?

If I want to create a URL using a variable I have two choices to encode the string. urlencode() and rawurlencode(). What exactly are the differences and which is preferred?
Gary Willoughby
  • 50,926
  • 41
  • 133
  • 199
405
votes
6 answers

How can I percent-encode URL parameters in Python?

If I do url = "http://example.com?p=" + urllib.quote(query) It doesn't encode / to %2F (breaks OAuth normalization) It doesn't handle Unicode (it throws an exception) Is there a better library?
Paul Tarjan
  • 48,968
  • 59
  • 172
  • 213
391
votes
24 answers

HTTP URL Address Encoding in Java

My Java standalone application gets a URL (which points to a file) from the user and I need to hit it and download it. The problem I am facing is that I am not able to encode the HTTP URL address properly... Example: URL: …
suDocker
  • 8,504
  • 6
  • 26
  • 26
385
votes
19 answers

Swift - encode URL

If I encode a string like this: var escapedString = originalString.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding) it doesn't escape the slashes /. I've searched and found this Objective C code: NSString *encodedString =…
MegaCookie
  • 5,017
  • 3
  • 21
  • 25
381
votes
7 answers

URL encoding in Android

How do you encode a URL in Android? I thought it was like this: final String encodedURL = URLEncoder.encode(urlAsString, "UTF-8"); URL url = new URL(encodedURL); If I do the above, the http:// in urlAsString is replaced by http%3A%2F%2F in…
hpique
  • 119,096
  • 131
  • 338
  • 476
318
votes
9 answers

How do you UrlEncode without using System.Web?

I am trying to write a windows client application that calls a web site for data. To keep the install to a minimum I am trying only use dlls in the .NET Framework Client Profile. Trouble is that I need to UrlEncode some parameters, is there an easy…
Martin Brown
  • 24,692
  • 14
  • 77
  • 122
309
votes
4 answers

URL encode sees “&” (ampersand) as “&” HTML entity

I am encoding a string that will be passed in a URL (via GET). But if I use escape, encodeURI or encodeURIComponent, & will be replaced with %26amp%3B, but I want it to be replaced with %26. What am I doing wrong?
dododedodonl
  • 4,585
  • 6
  • 30
  • 43
1
2 3
99 100