urlencode

URL-encoding and HTML-encoding NSStrings

强颜欢笑 提交于 2019-11-30 03:50:06
问题 Is their a method to encode/decode HTML and URL (in Xcode, using Objective-C)? [NSString stringWithContentsOfFile:<#(NSString *)path#> encoding:<#(NSStringEncoding)enc#> error:<#(NSError **)error#>] This doesn't seem to work how i expected. I thought it will convert special characters like "<" to equivalent HTML entities i.e. "<" in this case. Here's a reference to the w3school link related to this topic (general): HTML URL Encoding Reference HTML Entities Reference Thanking in anticipation.

System.Uri and encoded colon (:)

六眼飞鱼酱① 提交于 2019-11-30 03:35:44
问题 Before .Net 4.5, it seems that System.Uri would unencode encoded slashes, but this has since been fixed. Reference: https://stackoverflow.com/a/20733619/188740 I'm encountering the same problem with colons. System.Uri still unencodes encoded colons. Example: var uri = new Uri("http://www.example.com/?foo=http%3A%2F%2Fwww.example.com"); var s = uri.ToString(); //http://www.example.com/?foo=http:%2F%2Fwww.example.com Notice how %3A gets switched back to : by System.Uri. Is this a bug? What's

urllib.quote() throws KeyError

和自甴很熟 提交于 2019-11-30 01:17:22
To encode the URI, I used urllib.quote("schönefeld") but when some non-ascii characters exists in string, it thorws KeyError: u'\xe9' Code: return ''.join(map(quoter, s)) My input strings are köln, brønshøj, schönefeld etc. When I tried just printing statements in windows(Using python2.7, pyscripter IDE). But in linux it raises exception (I guess platform doesn't matter). This is what I am trying: from commands import getstatusoutput queryParams = "schönefeld"; cmdString = "http://baseurl" + quote(queryParams) print getstatusoutput(cmdString) Exploring the issue reason: in urllib.quote() ,

php javascript url encoding

[亡魂溺海] 提交于 2019-11-30 00:02:09
I have a html text. I had encoded it in php using urlencode function. I want to decode that text in the javascript. when i use unescape function in javascript it replaces all the special characters back but sapce is replaced by '+'. how can i do it correctly so that space is replaced as space itself??? Try using rawurlencode instead - urlencode does some things differently for "historical" reasons. See http://us.php.net/manual/en/function.urlencode.php for more information. PHP rawUrlEncode() == JavaScript encodeURIComponent() PHP rawUrlDecode() == JavaScript decodeURIComponent() Parenthesis

NSString with emoticons/emojis url encode

你说的曾经没有我的故事 提交于 2019-11-29 23:53:04
问题 I am trying to take the contents of a UITextField that may contain special characters and emojis and turn it into something I can pass in a GET request to a PHP service. If I do not encode the string at all, the emojis show up just fine (I can see them in the DB and they come back to me properly)... but if I add special chars (~!@#$%, etc.) the GET request chokes. So I run the string through the url encoder: [commentText stringByAddingPercentEscapesUsingEncoding:NSNonLossyASCIIStringEncoding]

URL/HTML Escaping/Encoding

冷暖自知 提交于 2019-11-29 21:49:51
I have always been confused with URL/HTML Encoding/Escaping. I am using PHP, so want to clear somethings up. Can I say that I should always use urlencode : for individual query string parts $url = 'http://test.com?param1=' . urlencode('some data') . '&param2=' . urlencode('something else'); htmlentities : for escaping special characters like <> so that if will be rendered properly by the browser Would there be any other places I might use each function. I am not good at all these escaping stuff, always confused by them ircmaxell First off, you shouldn't be using htmlentites around 99% of the

How to escape URL-encoded data in POST with HttpWebRequest

…衆ロ難τιáo~ 提交于 2019-11-29 17:59:36
问题 I am trying to send an URL-encoded post to a REST API implemented in PHP. The POST data contains two user-provided strings: WebRequest request = HttpWebRequest.Create(new Uri(serverUri, "rest")); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; request.Headers.Add("Content-Transfer-Encoding", "binary"); // Form the url-encoded credentials we'll use to log in StringBuilder builder = new StringBuilder(); builder.Append("user="); builder.Append

JS encodeURIComponent result different from the one created by FORM

≡放荡痞女 提交于 2019-11-29 17:36:08
I thought values entered in forms are properly encoded by browsers. But this simple test file "test_get_vs_encodeuri.html" shows it's not true: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title></title> </head><body> <form id="test" action="test_get_vs_encodeuri.html" method="GET" onsubmit="alert(encodeURIComponent(this.one.value));"> <input name="one" type="text" value="Euro-€"> <input type="submit" value="SUBMIT"> </form> </body></html> When

How to encode URL in Groovy?

自古美人都是妖i 提交于 2019-11-29 16:34:54
问题 Is there a kind of URLEncode in Groovy? I can't find any String → String URL encoding utility. Example: dehydrogenase (NADP+) → dehydrogenase%20(NADP%2b) ( + instead of %20 would also be acceptable, as some implementations do that) 回答1: You could use java.net.URLEncoder . In your example above, the brackets must be encoded too: def toEncode = "dehydrogenase (NADP+)" assert java.net.URLEncoder.encode(toEncode, "UTF-8") == "dehydrogenase+%28NADP%2B%29" You could also add a method to string's

Encoding spaces in UITextView / UITextField to URL format

喜欢而已 提交于 2019-11-29 14:13:24
问题 I'm trying to send the contents of UITextView or UITextField as parameters to a php file NSString *urlstr = [[NSString alloc] initWithFormat:@"http://server.com/file.php?name=%@&tags=%@&entry=%@",nameField.text, tagsField.text, dreamEntry.text]; When i log urlstr, the url format is ok just as long as the UITextView or UITextField don't contain spaces. How would i go about converting the spaces to %20 ? edit here is the code at present, which not only crashes but isn't encoding the url