url-encoding

How to decode url-encoded string in javascript

我怕爱的太早我们不能终老 提交于 2019-12-01 17:18:55
I use javascript / jquery to fill dom elements that contain umlauts: var text1 = "Unser platonisches Internetreich droht in die H%E4nde einer bewaffneten Miliz zu fallen." $("#quote1 span").html(unescape(text1)); How can I get rid of the url encoding e.g. "H%E4nde" and use "Hände" instead? I tried <meta charset="utf-8" /> <meta name="http-equiv" content="Content-type: text/html; charset=UTF-8"/> <script type="text/javascript" src="js/index.js" charset="utf-8"></script> But none of them seem to work... Thanks for help. That is not UTF-8, that is percent encoding also known as url encoding. You

How to avoid getting URL encoded paths from URL.getFile()?

我的梦境 提交于 2019-12-01 15:33:09
问题 I'm having the following problem when trying to get the path of a given resource: System.out.println("nf="+new File(".").getAbsolutePath()); System.out.println("od="+new File(this.getClass().getResource(".").getFile()); The output I get is: nf=C:\Users\current user\workspace\xyz\. od=C:\Users\current%20user\workspace\xyz\bin\something The problem lies with the %20 URL encoding thing. How to avoid it? Is there a direct way to avoid getting this kind of string in the first place, or should I

JSP 2.0 SEO friendly links encoding

时光总嘲笑我的痴心妄想 提交于 2019-12-01 15:20:47
问题 Currently I have something like this in my JSP <c:url value="/teams/${contact.id}/${contact.name}" /> The important part of my URL is the ID, I just put the name on it for SEO purposes (just like stackoverflow.com does). I was just wondering if there is a quick and clean way to encode the name (change spaces per +, latin chars removal, etc). I'd like it to be like this: <c:url value="/teams/${contact.id}/${supercool(contact.name)}" /> Is there a function like that out there or should I make

Is there a Java equivalent for C#'s HttpServerUtility.UrlTokenDecode?

邮差的信 提交于 2019-12-01 08:22:35
问题 How do I decode in Java a string that was encoded in C# using HttpServerUtility.UrlTokenEncode? 回答1: I tried using org.apache.commons.codec.binary.Base64 (The ctor accepts a parameter stating whether the encoding/decoding is url-safe) but turns out it is not implemented the same as UrlTokenEncode/Decode. I ended up migrating the C# implementation to Java: public static byte[] UrlTokenDecode(String input) { if (input == null) return new byte[0]; int len = input.length(); if (len < 1) return

Browser Support for UTF8 Encoded Characters in URL's

老子叫甜甜 提交于 2019-12-01 05:15:55
If I navigate to the following URL with a special UTF8 encoded character I get different results in web browsers: http://example.com/lörickè Firefox 37 - Shows the correct URL as above. Chrome 42 - Shows the correct URL as above. Edge - Shows the correct URL as above. IE 11 - Shows percent encoded URL http://example.com/l%c3%b6rick%c3%a8/ Where can I find a list of browsers and versions that support this feature and are there any announcements of whether the new Microsoft Edge browser supports this. This StackOverflow post highlights the above issue for those interested. unor What is shown in

What other characters beside ampersand (&) should be encoded in HTML href/src attributes?

萝らか妹 提交于 2019-12-01 04:57:46
Is the ampersand the only character that should be encoded in an HTML attribute? It's well known that this won't pass validation: <a href="http://domain.com/search?q=whatever&lang=en"></a> Because the ampersand should be & . Here's a direct link to the validation fail. This guy lists a bunch of characters that should be encoded, but he's wrong. If you encode the first "/" in http:// the href won't work. In ASP.NET, is there a helper method already built to handle this? Stuff like Server.UrlEncode and HtmlEncode obviously don't work - those are for different purposes. I can build my own simple

How to URL encode strings in C#

三世轮回 提交于 2019-12-01 03:22:18
How can we encode a string using the URL (RFC 1738) standard in C#? The following online tool is converting the strings using this standard http://www.freeformatter.com/url-encoder.html An example of the string I want to convert is test(brackets) and the encoded string should look like: test%28brackets%29 Dirk According to RFC 1738 : Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL. Neither HttpUtility.UrlEncode nor WebUtility.UrlEncode will encode those characters since the standard says

Is it advisable to have non-ascii characters in the URL?

时光毁灭记忆、已成空白 提交于 2019-12-01 02:09:14
问题 We are currently working on a I18N project. I am wondering what are the complications of having the non-ascii characters in the URL. If its not advisable, what are the alternatives to deal with this problem? EDIT (in response to Maxym's answer): The site is going to be local to specific country and I need not worry about the world wide public accessing this site. I understand that from usability point of view, It is really annoying . What are the other technical problem associated with this?

Browser Support for UTF8 Encoded Characters in URL's

家住魔仙堡 提交于 2019-12-01 02:07:44
问题 If I navigate to the following URL with a special UTF8 encoded character I get different results in web browsers: http://example.com/lörickè Firefox 37 - Shows the correct URL as above. Chrome 42 - Shows the correct URL as above. Edge - Shows the correct URL as above. IE 11 - Shows percent encoded URL http://example.com/l%c3%b6rick%c3%a8/ Where can I find a list of browsers and versions that support this feature and are there any announcements of whether the new Microsoft Edge browser

Ampersands in URLRewriter Query Strings

不想你离开。 提交于 2019-11-30 23:51:12
I have a query string parameter value that contains an ampersand. For example, a valid value for the parameter may be: a & b When I generate the URL that contains the parameter, I'm using System.Web.HTTPUtility.UrlEncode() to make each element URL-friendly. It's (correctly) giving me a URL like: http://example.com/foo?bar=a+%26b The problem is that ASP.NET's Request object is interpreting the (encoded) ampersand as a Query String parameter delimiter, and is thus splitting my value into 2 parts (the first has "bar" as the parameter name; the second has a null name). It appears that ASP.NET is