urlencode

C#: base64url according to RFC4648

[亡魂溺海] 提交于 2019-11-28 11:24:13
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("AA")); //returns "QUE1" but I would expect "QUE" Based on the comments, it sounds like

How to URL Encode a Backslash with R/RCurl

半城伤御伤魂 提交于 2019-11-28 10:29:07
问题 I'm currently trying to encode a string for insertion into a URL. My issue is that this seems to fail when my string contains a backslash. I've tried 4 approaches so far using the URLencode, curlEscape (from RCurl), and curlPercentEncode (from RCurl) functions, but none of them have been successful. > URLencode("hello\hello") Error: '\h' is an unrecognized escape in character string starting ""hello\h" > curlEscape("hello\hello") Error: '\h' is an unrecognized escape in character string

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

我是研究僧i 提交于 2019-11-28 09:47:55
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 characters seem to be encoded in the same way with both functions, except for the 'asterisk' character

HTTP query and URI encoding doubts [closed]

别来无恙 提交于 2019-11-28 09:45:30
问题 Recently I was researching HTTP query strings while wondering about possibilities on web service access interface API . And it seems very underspecified. In fact RFC 3986 (Uniform Resource Identifier (URI): Generic Syntax) doesn’t say anything about format of the query string fragment and ends on defining which characters are allowed and how to encode other characters. (I will return to this later.) The only thing I found was HTML specification on how forms are mangled into query string (HTML

How to encode URL using php like browsers do

喜夏-厌秋 提交于 2019-11-28 09:18:43
I have an URL like this http://www.example.com/Data/image/office-dôn-sì-à.jpg I want to copy that file to my server using copy function in php. So the first thing is to encode it to this (I think browsers do the same thing) http://www.example.com/Data/image/office-d%C3%B4n-s%C3%AC-%C3%A0.jpg But if I use function urlencode , full url will be encoded to http%3A%2F%2Fwww.example.com%2FData%2Fimage%2Foffice-d%C3%B4n-s%C3%AC-%C3%A0.jpg which is not an URL anymore and not what I want. Any help? So, the other answers here have largely ignored your post, it seems. Let's hope I have not done the same.

Urlencode and file_get_contents

旧城冷巷雨未停 提交于 2019-11-28 03:37:12
问题 We have an url like http://site.s3.amazonaws.com/images/some image @name.jpg inside $string What I'm trying to do (yes, there is a whitespace around the url): $string = urlencode(trim($string)); $string_data = file_get_contents($string); What I get (@ is also replaced): file_get_contents(http%3A%2F%2Fsite.s3.amazonaws.com%2Fimages%2Fsome+image+@name.jpg)[function.file-get-contents]: failed to open stream: No such file or directory If you copy/paste http://site.s3.amazonaws.com/images/some

Urlencode in Objective-C

六眼飞鱼酱① 提交于 2019-11-28 00:31:08
i'm trying to make url encode for long string by using this function NSData *PostData = [MyString dataUsingEncoding:NSUTF8StringEncoding]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://xxxxxxx.com/save.php"]]; [request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:PostData]; [request setHTTPMethod:@"POST"]; but i miss some data when save it to my sql for example if we have this string which contain special characters (

Django自定义分页并保存搜索条件

对着背影说爱祢 提交于 2019-11-27 23:07:46
Django自定义分页并保存搜索条件 1、自定义分页组件pagination.py import copy class Pagination: def __init__(self, current_page_num, all_count, request, per_page_num=10, page_count=11): """ 封装分页相关数据 :param current_page_num: 当前页码数 :param all_count: 数据库中总数据条数 :param per_page_num: 每页显示的数据量 :param page_count: 最大显示页数 """ try: current_page = int(current_page_num) except Exception as e: current_page = 1 # 页码数小于1时显示第一页 if current_page < 1: current_page = 1 # 取总页码数 self.all_page_count, temp = divmod(all_count, per_page_num) if temp: self.all_page_count += 1 # 页码数大于最大页码数时显示最后一页 if current_page > self.all_page_count: current

C# web request with POST encoding question

跟風遠走 提交于 2019-11-27 22:21:25
问题 On the MSDN site there is an example of some C# code that shows how to make a web request with POST'ed data. Here is an excerpt of that code: WebRequest request = WebRequest.Create ("http://www.contoso.com/PostAccepter.aspx "); request.Method = "POST"; string postData = "This is a test that posts this string to a Web server."; byte[] byteArray = Encoding.UTF8.GetBytes (postData); // (*) request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; Stream

url encoded forward slashes breaking my codeigniter app

隐身守侯 提交于 2019-11-27 22:16:19
i’m trying to create a url string that works like this: /app/process/example.com/index.html so in other words, /app/process/$URL i then retrieve the url with $this->uri->segment(3); the forward slashes in the URL will of course be a problem accessing uri segments, so i’ll go ahead and url encode the URL portion: /app/process/example.com%2Findex.html .. but now I just get a 404 saying ... Not Found The requested URL /app/process/example.com/index.html was not found on this server. it appears that my url encoding of forward slashes breaks CI’s URI parser. what can i do to get around this problem