urlencode

Objective-C and Swift URL encoding

ε祈祈猫儿з 提交于 2019-11-26 00:23:27
问题 I have a NSString like this: http://www. but I want to transform it to: http%3A%2F%2Fwww. How can I do this? 回答1: To escape the characters you want is a little more work. Example code iOS7 and above: NSString *unescaped = @"http://www"; NSString *escapedString = [unescaped stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]; NSLog(@"escapedString: %@", escapedString); NSLog output: escapedString: http%3A%2F%2Fwww The following are useful URL

How can I URL encode a string in Excel VBA?

烂漫一生 提交于 2019-11-25 23:46:43
问题 Is there a built-in way to URL encode a string in Excel VBA or do I need to hand roll this functionality? 回答1: No, nothing built-in ( until Excel 2013 - see this answer ). There are three versions of URLEncode() in this answer. A function with UTF-8 support. You should probably use this one (or the alternative implementation by Tom) for compatibility with modern requirements. For reference and educational purposes, two functions without UTF-8 support: one found on a third party website,

post get urlencode urldecode

こ雲淡風輕ζ 提交于 2019-11-25 23:08:59
$_GET 通过 URL 参数传递给当前脚本的变量的数组。 Note : GET 是通过 urldecode() 传递的。 也就是说已经被decode过了,无需再次decode 当 HTTP POST 请求的 Content-Type 是 application/x-www-form-urlencoded 或 multipart/form-data 时,会将变量以关联数组形式传入当前脚本。 urlencode: urlencode — 编码 URL 字符串 返回值 返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号( % )后跟两位十六进制数,空格则编码为加号( + )。此编码与 WWW 表单 POST 数据的编码方式是一样的,同时与 application/x-www-form-urlencoded 的媒体类型编码方式一样 urldecode: 含义:urldecode — 解码已编码的 URL 字符串 具体说明: 解码给出的已编码字符串中的任何 %## 。 加号(' + ')被解码成一个空格字符。 Warning : 超全局变量 $_GET 已经被解码了。对 $_GET 里的元素使用 urldecode() 将会导致不可预计和危险的结果。 来源: CSDN 作者: 子弹头99 链接: https://blog.csdn.net/qq_41082746

When to encode space to plus (+) or %20?

早过忘川 提交于 2019-11-25 22:37:00
问题 Sometimes the spaces get URL encoded to the + sign, some other times to %20 . What is the difference and why should this happen? 回答1: + means a space only in application/x-www-form-urlencoded content, such as the query part of a URL: http://www.example.com/path/foo+bar/path?query+name=query+value In this URL, the parameter name is query name with a space and the value is query value with a space, but the folder name in the path is literally foo+bar , not foo bar . %20 is a valid way to encode

HTTP URL Address Encoding in Java

不问归期 提交于 2019-11-25 22:26:45
问题 My Java standalone application gets a URL (which points to a file) from the user and I need to hit it and download it. The problem I am facing is that I am not able to encode the HTTP URL address properly... Example: URL: http://search.barnesandnoble.com/booksearch/first book.pdf java.net.URLEncoder.encode(url.toString(), \"ISO-8859-1\"); returns me: http%3A%2F%2Fsearch.barnesandnoble.com%2Fbooksearch%2Ffirst+book.pdf But, what I want is http://search.barnesandnoble.com/booksearch/first

Query-string encoding of a Javascript Object

孤人 提交于 2019-11-25 22:26:41
问题 Do you know a fast and simple way to encode a Javascript Object into a string that I can pass via a GET Request? No jQuery , no other frameworks - just plain Javascript :) 回答1: like this? serialize = function(obj) { var str = []; for (var p in obj) if (obj.hasOwnProperty(p)) { str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); } return str.join("&"); } console.log(serialize({ foo: "hi there", bar: "100%" })); // foo=hi%20there&bar=100%25 Edit: this one also converts recursive

URL encoding in Android

醉酒当歌 提交于 2019-11-25 22:24:32
问题 How do you encode a URL in Android? I thought it was like this: final String encodedURL = URLEncoder.encode(urlAsString, \"UTF-8\"); URL url = new URL(encodedURL); If I do the above, the http:// in urlAsString is replaced by http%3A%2F%2F in encodedURL and then I get a java.net.MalformedURLException when I use the URL. 回答1: You don't encode the entire URL, only parts of it that come from "unreliable sources". String query = URLEncoder.encode("apples oranges", "utf-8"); String url = "http:/

Swift - encode URL

左心房为你撑大大i 提交于 2019-11-25 21:56:48
问题 If I encode a string like this: var escapedString = originalString.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding) it doesn\'t escape the slashes / . I\'ve searched and found this Objective C code: NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes( NULL, (CFStringRef)unencodedString, NULL, (CFStringRef)@\"!*\'();:@&=+$,/?%#[]\", kCFStringEncodingUTF8 ); Is there an easier way to encode an URL and if not, how do I write this in Swift? 回答1: Swift 3 In

Java URL encoding of query string parameters

試著忘記壹切 提交于 2019-11-25 21:41:09
问题 Say I have a URL http://example.com/query?q= and I have a query entered by the user such as: random word £500 bank $ I want the result to be a properly encoded URL: http://example.com/query?q=random%20word%20%A3500%20bank%20%24 What\'s the best way to achieve this? I tried URLEncoder and creating URI/URL objects but none of them come out quite right. 回答1: URLEncoder should be the way to go. You only need to keep in mind to encode only the individual query string parameter name and/or value,

How to urlencode data for curl command?

馋奶兔 提交于 2019-11-25 20:13:31
I am trying to write a bash script for testing that takes a parameter and sends it through curl to web site. I need to url encode the value to make sure that special characters are processed properly. What is the best way to do this? Here is my basic script so far: #!/bin/bash host=${1:?'bad host'} value=$2 shift shift curl -v -d "param=${value}" http://${host}/somepath $@ Jacob R Use curl --data-urlencode ; from man curl : This posts data, similar to the other --data options with the exception that this performs URL-encoding. To be CGI-compliant, the <data> part should begin with a name