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
252
votes
6 answers

What's the difference between EscapeUriString and EscapeDataString?

If only deal with url encoding, I should use EscapeUriString?
user496949
  • 83,087
  • 147
  • 309
  • 426
241
votes
19 answers

URLEncoder not able to translate space character

I am expecting System.out.println(java.net.URLEncoder.encode("Hello World", "UTF-8")); to output: Hello%20World (20 is ASCII Hex code for space) However, what I get is: Hello+World Am I using the wrong method? What is the correct method I should be…
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
211
votes
18 answers

How to create query parameters in Javascript?

Is there any way to create the query parameters for doing a GET request in JavaScript? Just like in Python you have urllib.urlencode(), which takes in a dictionary (or list of two tuples) and creates a string like 'var1=value1&var2=value2'.
cnu
  • 36,135
  • 23
  • 65
  • 63
200
votes
6 answers

URL Encode and Decode in ASP.NET Core

HttpContext.Current.Server.UrlEncode This does only work in .NET Framework. How can I encode or decode URI arguments in ASP.NET Core?
wtf512
  • 4,487
  • 9
  • 33
  • 55
197
votes
6 answers

Server.UrlEncode vs. HttpUtility.UrlEncode

Is there a difference between Server.UrlEncode and HttpUtility.UrlEncode?
Manu
  • 28,753
  • 28
  • 75
  • 83
168
votes
8 answers

How to URL encode a string in Ruby

How do I URI::encode a string like: \x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a to get it in a format like: %124Vx%9A%BC%DE%F1%23Eg%89%AB%CD%EF%124Vx%9A as per RFC 1738? Here's what I tried: irb(main):123:0>…
HRÓÐÓLFR
  • 5,842
  • 5
  • 32
  • 35
159
votes
6 answers

How to encode the plus (+) symbol in a URL

The URL link below will open a new Google mail window. The problem I have is that Google replaces all the plus (+) signs in the email body with blank space. It looks like it only happens with the + sign. How can I remedy this? (I am working on a…
user523234
  • 14,323
  • 10
  • 62
  • 102
157
votes
9 answers

JavaScript URL Decode function

What's the best JavaScript URL decode utility? Encoding would be nice too and working well with jQuery is an added bonus.
at.
  • 50,922
  • 104
  • 292
  • 461
155
votes
13 answers

How to encode a URL in Swift

This is my URL. The problem is, that the address field is not being appended to urlpath. Does anyone know why that is? var address:string address = "American Tourister, Abids Road, Bogulkunta, Hyderabad, Andhra Pradesh, India" let urlpath =…
user3541467
  • 1,693
  • 3
  • 12
  • 6
146
votes
5 answers

In a URL, should spaces be encoded using %20 or +?

In a URL, should I encode the spaces using %20 or +? For example, in the following example, which one is correct? www.mydomain.com?type=xbox%20360 www.mydomain.com?type=xbox+360 Our company is leaning to the former, but using the Java method…
MegaByter
  • 1,461
  • 2
  • 9
  • 3
141
votes
13 answers

Objective-C and Swift URL encoding

I have a NSString like this: http://www. but I want to transform it to: http%3A%2F%2Fwww. How can I do this?
Usi Usi
  • 2,967
  • 5
  • 38
  • 69
136
votes
4 answers

Should I URL-encode POST data?

I'm POSTing data to an external API (using PHP, if it's relevant). Should I URL-encode the POST variables that I pass? Or do I only need to URL-encode GET data? UPDATE: This is my PHP, in case it is relevant: $fields = array( …
Richard
  • 31,629
  • 29
  • 108
  • 145
129
votes
9 answers

Encoding URL query parameters in Java

How does one encode query parameters to go on a url in Java? I know, this seems like an obvious and already asked question. There are two subtleties I'm not sure of: Should spaces be encoded on the url as "+" or as "%20"? In chrome if I type in…
waterlooalex
  • 13,642
  • 16
  • 78
  • 99
122
votes
6 answers

How can I properly URL encode a string in PHP?

I'm making a search page, where you type a search query and the form is submitted to search.php?query=your query. What PHP function is the best and that I should use for encoding/decoding the search query?
Ali
  • 261,656
  • 265
  • 575
  • 769
116
votes
5 answers

What is the proper way to URL encode Unicode characters?

I know of the non-standard %uxxxx scheme but that doesn't seem like a wise choice since the scheme has been rejected by the W3C. Some interesting examples: The heart character. If I type this into my browser: http://www.google.com/search?q=♥ Then…
Josh Gibson
  • 21,808
  • 28
  • 67
  • 63