urlencode

用JS解码PHP的urlencode编码

旧城冷巷雨未停 提交于 2019-12-04 05:48:18
JS的编码、解码方法里,decodeURI和PHP的urlencode方法不同,无法对PHP的urlencode进行解码。 function URLdecode(str) { var ret = ""; for(var i=0;i<str.length;i++) { var chr = str.charAt(i); if(chr == "+") { ret += " "; }else if(chr=="%") { var asc = str.substring(i+1,i+3); if(parseInt("0x"+asc)>0x7f) { ret += decodeURI("%"+ str.substring(i+1,i+9)); i += 8; }else { ret += String.fromCharCode(parseInt("0x"+asc)); i += 2; } }else { ret += chr; } } return ret; } alert(URLdecode("<?php echo $test_1 ?>")); 来源: oschina 链接: https://my.oschina.net/u/2893981/blog/810394

S3 PUT doesn't work with pre-signed URL in javascript

这一生的挚爱 提交于 2019-12-04 05:40:55
I have generated a pre-signed S3 URL in java for HTTP PUT method. A slightly modified version of the URL: https://s3.amazonaws.com/somebucket/pre-signed-url-key-2?AWSAccessKeyId=BKIAIQ6H5Z7BG6KZ2ZUA&Expires=1425617244&Signature=GWcRM5ZIrAKnMJBsxyfm%2F9fyuBk%3D I know that it is a valid pre-signed url since I can use it with curl to upload a file curl -v --upload-file somefile.txt "https://s3.amazonaws.com/somebucket/pre-signed-url-key-2?AWSAccessKeyId=BKIAIQ6H5Z7BG6KZ2ZUA&Expires=1425617244&Signature=GWcRM5ZIrAKnMJBsxyfm%2F9fyuBk%3D" When I try to upload a file to the same URL using the

URL percent encoding is not working

好久不见. 提交于 2019-12-04 05:22:15
问题 I'm trying to do a somewhat simple thing with no luck - I want to display Hebrew/Arabic characters in my URL. For example: I want the URL to display a file named: aאm.php So I've percent encoded the middle UTF8 characters and the result is: a%D7%90m.php . I've uploaded a%D7%90m.php to my server (Apache) and tried to request the pages www.example.com/a%D7%90m.php & www.example.com/aאm.php but my server responded: The requested URL /a%D7%90m.php was not found on this server. So I tried to

Angular Resource Encoding URL

拟墨画扇 提交于 2019-12-04 03:54:59
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 there a way to prevent the % from being encoded to a %25 in this case? I've tried a combination of

C - URL encoding

与世无争的帅哥 提交于 2019-12-04 03:13:20
问题 Is there a simple way to do URL encode in C? I'm using libcurl but I haven't found a method. Specifically, I need to do percent escapes. 回答1: curl_escape which apparently has been superseded by curl_easy_escape 回答2: In C based on wikipedia, without having to alloc and free. Make sure output buffer is at least 3X input URL string. Usually you only need to encode up to maybe 4K as URLs tend to be short so just do it on the stack. char rfc3986[256] = {0}; char html5[256] = {0}; void url_encoder

Simple ascii url encoding with python

萝らか妹 提交于 2019-12-04 02:15:57
问题 look at that: import urllib print urllib.urlencode(dict(bla='Ã')) the output is bla=%C3%BC what I want is simple, I want the output in ascii instead of utf-8, so I need the output: bla=%C3 if I try: urllib.urlencode(dict(bla='Ã'.decode('iso-8859-1'))) doesn't work (all my python files are utf-8 encoded): 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128) In production, the input comes unicoded. 回答1: Have a look at unicode transliteration in python: from unidecode

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

孤街醉人 提交于 2019-12-03 23:28:05
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 version, hidden somewhere else, or am I completely off base? By default, new projects in Visual Studio

C#中的System.Web.HttpUtility.UrlEncode转码问题

旧巷老猫 提交于 2019-12-03 22:42:37
最近需要与JAVA程序对接口,其中遇到的URL转码问题: Java中URL编码所用的 URLEncoder.encode 产生的字符是大写且英文 '(',')' 是分别转成 '%28'和 '%29' 而C#中的 HttpUtility.UrlEncode产生的字符是小写且英文括号并没有转码 ,所以两者生成的字符不一致,导致系统出错。 下面贴出解决方案: 1、字符大小写问题: //对转码后的字符进行大写转换,不会把参数转换成大写(采用) public static string GetUpperEncode(string encodeUrl) { var result = new StringBuilder(); int index = int.MinValue; for (int i = 0; i < encodeUrl.Length; i++) { string character = encodeUrl[i].ToString(); if (character == "%") index = i; if (i - index == 1 || i - index == 2) character = character.ToUpper(); result.Append(character); } return result.ToString(); } //网上搜的其他方法

How to “URL decode” a string in Emacs Lisp?

只谈情不闲聊 提交于 2019-12-03 22:21:44
I've got a string like "foo%20bar" and I want "foo bar" out of it. I know there's got to be a built-in function to decode a URL-encoded string (query string) in Emacs Lisp, but for the life of me I can't find it today, either in my lisp/ folder or with google. Anybody remember what it's called? org-link-unescape does the job for very simple cases ... w3m-url-decode-string is better, but it isn't built in and the version I have locally isn't working with Emacs 23. url-unhex-string In my case I needed to do this interactively. The previous answers gave me the right functions to call, then it was

urlencode() the 'asterisk' (star?) character

萝らか妹 提交于 2019-12-03 19:48:01
问题 I'm testing PHP urlencode() vs. Java java.net.URLEncoder.encode() . Java String all = ""; for (int i = 32; i < 256; ++i) { all += (char) i; } System.out.println("All characters: -||" + all + "||-"); try { System.out.println("Encoded characters: -||" + URLEncoder.encode(all, "utf8") + "||-"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } PHP $all = ""; for($i = 32; $i < 256; ++$i) { $all = $all.chr($i); } echo($all.PHP_EOL); echo(urlencode(utf8_encode($all)).PHP_EOL); All