url-encoding

Can urls have UTF-8 characters?

怎甘沉沦 提交于 2019-11-27 06:52:07
问题 I was curious if I should encode urls with ASCII or UTF-8. I was under the belief that urls cannot have non-ASCII characters, but someone told me they can have UTF-8, and I searched around and couldn't quite find which one is true. Does anyone know? 回答1: There are two parts to this, but they both amount to "yes". With IDNA, it is possible to register domain names using the full Unicode repertoire (with a few minor twists to prevent ambiguities and abuse). The path part is not strictly

NameValueCollection to URL Query?

我的未来我决定 提交于 2019-11-27 06:43:11
I know i can do this var nv = HttpUtility.ParseQueryString(req.RawUrl); But is there a way to convert this back to a url? var newUrl = HttpUtility.Something("/page", nv); Ahmad Mageed Simply calling ToString() on the NameValueCollection will return the name value pairs in a name1=value1&name2=value2 querystring ready format. Note that NameValueCollection types don't actually support this and it's misleading to suggest this, but the behavior works here due to the internal type that's actually returned, as explained below. Thanks to @mjwills for pointing out that the HttpUtility.ParseQueryString

How do you unescape URLs in Java?

人盡茶涼 提交于 2019-11-27 06:33:51
问题 When I read the xml through a URL's InputStream, and then cut out everything except the url, I get "http://cliveg.bu.edu/people/sganguly/player/%20Rang%20De%20Basanti%20-%20Tu%20Bin%20Bataye.mp3". As you can see, there are a lot of "%20"s. I want the url to be unescaped. Is there any way to do this in Java, without using a third-party library? 回答1: This is not unescaped XML, this is URL encoded text. Looks to me like you want to use the following on the URL strings. URLDecoder.decode(url);

C#: base64url according to RFC4648

徘徊边缘 提交于 2019-11-27 06:14:30
问题 I'm looking for a (fast) standard implementation for base64url according to RFC4648 in C#. I found HttpServerUtility.UrlTokenEncode but it looks like this doesn't follow RFC4648 (UrlTokenEncode adds a number at the end which indicates the number of = signs that were removed; see here and here). Example: base64 encoding: Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("AA")); //returns "QUE=" base64url encoding: HttpServerUtility.UrlTokenEncode(System.Text.Encoding.ASCII.GetBytes(

What is %2C in a URL?

不羁的心 提交于 2019-11-27 04:58:55
问题 I'm trying to understand the structure of a URL, and I'm seeing a lot of %2C . I'm guessing this is a result of some encoding. What does that stand for? 回答1: Check out http://www.asciitable.com/ Look at the Hx , (Hex) column; 2C maps to , Any unusual encoding can be checked this way +----+-----+----+-----+----+-----+----+-----+ | Hx | Chr | Hx | Chr | Hx | Chr | Hx | Chr | +----+-----+----+-----+----+-----+----+-----+ | 00 | NUL | 20 | SPC | 40 | @ | 60 | ` | | 01 | SOH | 21 | ! | 41 | A | 61

Python not able to open file with non-english characters in path

爷,独闯天下 提交于 2019-11-27 04:32:18
问题 I have a file with the following path : D:/bar/クレイジー・ヒッツ!/foo.abc I am parsing the path from a XML file and storing it in a variable called path in the form of file://localhost/D:/bar/クレイジー・ヒッツ!/foo.abc Then, the following operations are being done : path=path.strip() path=path[17:] #to remove the file://localhost/ part path=urllib.url2pathname(path) path=urllib.unquote(path) The error is : IOError: [Errno 2] No such file or directory: 'D:\\bar\\\xe3\x82\xaf\xe3\x83\xac\xe3\x82\xa4\xe3\x82

Why is the return value of String.addingPercentEncoding() optional?

喜欢而已 提交于 2019-11-27 04:29:24
问题 The signature of the String method for percent-escaping is: func addingPercentEncoding(withAllowedCharacters: CharacterSet) -> String? (This was stringByAddingPercentEncodingWithAllowedCharacters in Swift 2.) Why does this method return an optional? The documentation says that the method returns nil “if the transformation is not possible,” but it's unclear under what circumstances the escaping transformation could fail: Characters are escaped using UTF-8, which is a complete Unicode encoding.

A html space is showing as %2520 instead of %20

独自空忆成欢 提交于 2019-11-27 03:54:30
Passing a filename to the firefox browser causes it to replace spaces with %2520 instead of %20 . I have the following HTML in a file called myhtml.html : <img src="C:\Documents and Settings\screenshots\Image01.png"/> When I load myhtml.html into firefox, the image shows up as a broken image. So I right click the link to view the picture and it shows this modified URL: file:///c:/Documents%2520and%2520Settings/screenshots/Image01.png ^ ^-----Firefox changed my space to %2520. What the heck? It converted my space into a %2520 . Shouldn't it be converting it to a %20 ? How do I change this HTML

Do ampersands still need to be encoded in URLs in HTML5?

我只是一个虾纸丫 提交于 2019-11-27 03:45:09
问题 I learned recently (from these questions) that at some point it was advisable to encode ampersands in href parameters. That is to say, instead of writing: <a href="somepage.html?x=1&y=2">...</a> One should write: <a href="somepage.html?x=1&y=2">...</a> Apparently, the former example shouldn't work, but browser error recovery means it does. Is this still the case in HTML5? We're now past the era of draconian XHTML requirements. Was this a requirement of XHTML's strict handling, or is it really

PHP URL Encoding / Decoding

旧街凉风 提交于 2019-11-27 02:14:55
I used the solution accepted for this question for encrypting by id for example in /index.php?id=3 . The problem is I cannot send the encrypted value as an url, example /index.php?id=dsf13f3343f23/23= . Because sometimes it will have weird characters in the url e.g. notice the = sign in the end Pascal MARTIN The weird characters in the values passed in the URL should be escaped, using urlencode( ). For example, the following portion of code : echo urlencode('dsf13f3343f23/23='); would give you : dsf13f3343f23%2F23%3D Which works fine, as an URL parameter. And if you want to build aquery string