urlencode

Angular Resource Encoding URL

微笑、不失礼 提交于 2019-12-05 22:07:46
问题 I have a resource defined as follows: app.factory("DatumItem", function($resource) { return $resource('/data/:id', {id: '@id'}); }); In my view I have: <div ng-click="go('/datum/' + d.to_param)">Test</div> where go() is defined in my controller as: $scope.go = function (params) { $location.path(params); }; For the item in question, d.param is equal to TkZUOWZwcnc9Uldo%0ASzRvd2FiWk But when I call DatumItem.get() with the correct ID, it is changing the id to TkZUOWZwcnc9Uldo%250ASzRvd2FiWk Is

PHP $_GET var with urlencode and “&” bug

a 夏天 提交于 2019-12-05 19:39:07
In my code, I create a link like this: $link = 'http://www.mydomain.com/'.urlencode($str).'/1'; I use url-rewriting and the rule in my htaccess file looks like this: rewriteRule ^(.+)/(.*)$ index.php?var1=$1&var2=$2 [NC,L] This code is working fine for almost every strings. But sometimes, the string to encode contains "&". The urlencode function encodes it corectly, but when I read the $_GET array in php, it looks like this (with $str = 'substring1&substring2'): 'var1' => 'substring1' (without "&") 'substring2' => '' (without "&") 'var2' => 1 I really need the "&" in my var. Is there a way to

C# UrlEncode 编码

感情迁移 提交于 2019-12-05 17:19:51
在开发中遇见一个将文件流转换为Base64码,这个码中有特殊字符需要处理,然后选择用 HttpUtility.UrlEncode进行编码 HttpUtility.UrlEncode(text); //utf-8 编码 HttpUtility.UrlDecode(text); //utf-8 解码 HttpUtility.UrlEncode(text, System.Text.Encoding.GetEncoding(936)); //gb2312编码 HttpUtility.UrlDecode(text, System.Text.Encoding.GetEncoding(936)); //gb2312解码 View Code 后来查找文章发现这个方法会将空格转换为+ 这是就需要将+替换为空格对应的ASCII码(%20) fileStream = HttpUtility.UrlEncode(fileStream); fileStream = fileStream ("+", "%20"); View Code 参考 https://www.cnblogs.com/luckyuns/p/6396792.html 来源: https://www.cnblogs.com/ZJ199012/p/11936391.html

urlencode only the directory and file names of a URL

不想你离开。 提交于 2019-12-05 16:41:41
问题 I need to URL encode just the directory path and file name of a URL using PHP. So I want to encode something like http://example.com/file name and have it result in http://example.com/file%20name . Of course, if I do urlencode('http://example.com/file name'); then I end up with http%3A%2F%2Fexample.com%2Ffile+name . The obvious (to me, anyway) solution is to use parse_url() to split the URL into scheme, host, etc. and then just urlencode() the parts that need it like the path. Then, I would

Why can't I find or use UrlEncode in Visual Studio 2010?

可紊 提交于 2019-12-05 11:58:27
问题 I have a string that I'd like to encode into the standard URL format. From what I've found, I should be able to do this via the httpUtility.urlEncode method, but I don't seem to have that available. I've added "using" references to both System.Web and System.Net to no avail. I've also seen other references to server.urlEncode amongst other variants, but I don't see the method anywhere. I'm using the latest version of C# in Visual Studio 2010. Is the method called something different in this

In the Yesod ecosystem, what is the best way to urlencode some Text?

牧云@^-^@ 提交于 2019-12-05 06:42:10
I'd like to url-encode some Text (e.g., replace each space with a %20, etc.). I found "HTTP" Network.HTTP.Base.urlEncode and could use that, but I'm wondering if there's something else that's normally used in the Yesod ecosystem. Michael Snoyman Unfortunately, due to the complexity of URL escaping, the real answer is "it depends." There are slightly different rules for the percent encoding of path segments and query strings, for example. I don't know exactly what you're trying to encode, but I'd recommend sticking to the http-types package. One place to start would be urlEncode , though there

Is there a common Java library that will handle URL encoding/decoding for a collection of strings?

空扰寡人 提交于 2019-12-05 05:21:23
I often have to url encode or decode a large collection or array of strings. Besides iterating through them and using the static URLDecoder.decode(string, "UTF-8"), are there any libraries out there that will make this type of operation more performant? A colleague insists that using the static method to decode the strings in-place is not thread safe. Why would that be? kaliatech The JDK URLDecoder wasn't implemented efficiently. Most notably, internally it relies on StringBuffer (which unnecessarily introduces synchronization in the case of URLDecoder). The Apache commons provides URLCodec ,

Are IRIs valid as HTML attribute values?

荒凉一梦 提交于 2019-12-05 04:21:49
Is it valid HTML to use IRIs containing non-ASCII characters as attribute values (e.g. for href attributes) instead of URIs? Are there any differences among the HTML flavors (HTML and XHTML, 4 and 5)? At least RFC 3986 seems to imply that it isn't. I realize that it would probably be safer (regarding older and IRI-unaware software) to use percent encoding, but I'm looking for a definitive answer with regards to the standard. So far, I've done some tests with the W3C validator , and unescaped unicode characters in URIs don't trigger any warnings or errors with HTML 4/5 and XHTML 4/5 doctypes

should encodeURI ever be used?

若如初见. 提交于 2019-12-05 03:53:38
Is there any valid use for javascript's encodeURI function? As far as I can tell, when you are trying to make a HTTP request you should either have: a complete URI some fragment you want to put in a URI, which is either a unicode string or UTF-8 byte sequence In the first case, obviously nothing needs to be done to request it. Note: if you actually want to pass it as a parameter (e.g ?url=http...) then you actually have an instance of the second case that happens to look like a URI. In the second case, you should always convert a unicode string into UTF-8, and then call encodeURIComponent to

HttpUtility.ParseQueryString without decoding special characters

孤者浪人 提交于 2019-12-05 01:19:45
Uri uri = new Uri(redirectionUrl); NameValueCollection col = HttpUtility.ParseQueryString(uri.Query) uri.Query is already decoded - so is there any way I can prevent ParseQueryString decoding it again? Apart from that - is there another method to retrieve a name value collection from a Uri without modifying any components? Encoding the uri.Query before passing it to ParseQueryString is the first thing that comes to my head. UPDATE Just checked the ParseQueryString method with Reflector: it assumes that the query string is encoded and you can't do anything with it... Bummer. So I think you need