urlencode

What's the difference between EscapeUriString and EscapeDataString?

﹥>﹥吖頭↗ 提交于 2019-11-27 10:45:44
If only deal with url encoding, I should use EscapeUriString ? Use EscapeDataString always (for more info about why, see Livven's answer below) Edit : removed dead link to how the two differ on encoding I didn't find the existing answers satisfactory so I decided to dig a little deeper to settle this issue. Surprisingly, the answer is very simple: There is no valid reason to ever use Uri.EscapeUriString . If you need to percent-encode a string, always use Uri.EscapeDataString . Why is this? According to the documentation : Use the EscapeUriString method to prepare an unescaped URI string to be

Ruby url encoding string

帅比萌擦擦* 提交于 2019-11-27 10:24:31
How do I URI::encode a string like: \x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a To get it in a format like: %124Vx%9A%BC%DE%F1%23Eg%89%AB%CD%EF%124Vx%9A (as per RFC 1738) Here's what I've tried: irb(main):123:0> URI::encode "\x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\x78\x9a" ArgumentError: invalid byte sequence in UTF-8 from /usr/local/lib/ruby/1.9.1/uri/common.rb:219:in `gsub' from /usr/local/lib/ruby/1.9.1/uri/common.rb:219:in `escape' from /usr/local/lib/ruby/1.9.1/uri/common.rb:505:in `escape' from (irb):123 from /usr

urllib.urlencode doesn't like unicode values: how about this workaround?

谁都会走 提交于 2019-11-27 09:50:25
问题 If I have an object like: d = {'a':1, 'en': 'hello'} ...then I can pass it to urllib.urlencode , no problem: percent_escaped = urlencode(d) print percent_escaped But if I try to pass an object with a value of type unicode , game over: d2 = {'a':1, 'en': 'hello', 'pt': u'olá'} percent_escaped = urlencode(d2) print percent_escaped # This fails with a UnicodeEncodingError So my question is about a reliable way to prepare an object to be passed to urlencode . I came up with this function where I

url encode behaving differently in Firefox and Internet Explorer

女生的网名这么多〃 提交于 2019-11-27 08:33:35
问题 I want to send a user's entry to google's geocode API. In doing so, I detected a problem. When I send the user input (e.g. "köln+Germany") through my script to the api in Firefox it works great. In Internet Explorer however it's not working. Here's the exempt of my code that's enough to show the problem: header('Content-type: text/html; charset=UTF-8'); header('Cache-Control: no-cache, must-revalidate'); $loc = urlencode($_GET['loc']); echo $address = "http://maps.googleapis.com/maps/api

Prefilling gmail compose screen with HTML text

冷暖自知 提交于 2019-11-27 07:30:41
Hi guys I found out that in order to open a GMAIL compose screen you'd have to be logged in and open the following link: https://mail.google.com/a/domain/?view=cm&fs=1&tf=1&source=mailto&to=WHOEVER%40COMPANY.COM&su=SUBJECTHERE&cc=WHOEVER%40COMPANY.COM&bcc=WHOEVER%40COMPANY.COM&body=PREPOPULATEDBODY Replacing the variables fills in the corresponding places on the compose form. However if I want to enter into the body multiline text or line breaks its just not working even if I urlencode it. Any ideas here? Check that your UrlEncode method really translates newlines into "%0a". Here's an example

facebook error 'Error validating verification code'

╄→гoц情女王★ 提交于 2019-11-27 06:22:45
very strange error. i use gide http://developers.facebook.com/docs/authentication/ . so i create request to fb and pass redirect_uri. i use test site on localhost. so if i pass redirect_uri= http://localhost/test_blog/index.php it works fine, but if i pass redirect_uri= http://localhost/test_blog/index.php?r=site/oauth2 it don't want work. i try to use redirect_uri= . urlencode(' http://localhost/test_blog/index.php?r=site/oauth2 ) but not work. i try to explaine. i success get code, but when i access https://graph.facebook.com/me?access_token i get error 'Error validating verification code'.

C#: base64url according to RFC4648

徘徊边缘 提交于 2019-11-27 06:14:30
问题 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(

How can I stop the browser from url-encoding form values on GET

会有一股神秘感。 提交于 2019-11-27 05:17:44
I have a form with method="get" . In the form I need to pass the URL of a CSS file but it is encoding it to http%3A%2F%2Fwww... etc. Is there a way to stop the encoding of the URL as it is breaking the file. Thanks Background It's a bit more subtle than one might think at first sight. For any URL, which is a specific form of the URI standard, certain characters are special. Among the special characters are : (scheme separator) and / (path or hierarchy separator), here's the full list of reserved symbols from RFC-2396 : reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," It has

How does one encode and decode a string with Python for use in a URL?

偶尔善良 提交于 2019-11-27 04:47:18
问题 I have a string like this: String A: [ 12234_1_Hello'World_34433_22acb_4554344_accCC44 ] I would like to encrypt String A to be used in a clean URL. something like this: String B: [ cYdfkeYss4543423sdfHsaaZ ] Is there a encode API in python, given String A, it returns String B? Is there a decode API in python, given String B, it returns String A? 回答1: One way of doing the encode/decode is to use the package base64, for an example: import base64 import sys encoded = base64.b64encode(sys.stdin

Pass a percent (%) sign in a url and get exact value of it using php

我只是一个虾纸丫 提交于 2019-11-27 04:46:11
I am trying to pass percent (%) sign in url like %B6011000995504101^SB but when I echo, it returns ♦011000995504101^SB I want exact same value as I pass it in URL. I have tried to use urlencode() function, but it give me output like this... %B6011000995504101%5ESB please help me regarding this Answer: To send a % sign in a url, instead send %25 . In your case, in order for php to see a percent sign, you must pass the character string %25B6011000995504101^SB to the server. Why: In URLs, the percent sign has special meaning. Is used to encode special characters. For example, & is the separator