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).

2072 questions
2604
votes
20 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
  • 499,078
  • 194
  • 614
  • 709
765
votes
12 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,072
  • 3
  • 15
  • 25
605
votes
13 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
  • 7,872
  • 5
  • 28
  • 36
556
votes
42 answers

Query-string encoding of a Javascript Object

Do you know 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
  • 13,486
  • 7
  • 48
  • 68
532
votes
5 answers

When to encode space to plus (+) or %20?

Sometimes the spaces get URL encoded to the + sign, some other times to %20. What is the difference and why should this happen?
Muhammad Hewedy
  • 26,344
  • 42
  • 116
  • 201
397
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
  • 46,098
  • 37
  • 127
  • 193
379
votes
35 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
  • 16,951
  • 4
  • 26
  • 23
374
votes
23 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,244
  • 6
  • 24
  • 26
372
votes
13 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
  • 6,790
  • 9
  • 40
  • 58
352
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
  • 112,774
  • 126
  • 328
  • 461
337
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
  • 4,349
  • 3
  • 15
  • 22
337
votes
5 answers

How to 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
  • 44,540
  • 54
  • 163
  • 207
314
votes
8 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
  • 22,802
  • 13
  • 71
  • 107
298
votes
3 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,427
  • 6
  • 28
  • 42
216
votes
5 answers

What's the difference between EscapeUriString and EscapeDataString?

If only deal with url encoding, I should use EscapeUriString?
user496949
  • 75,601
  • 138
  • 297
  • 413
1
2 3
99 100