urlencode

post image using worklight http adapter proper format

本小妞迷上赌 提交于 2019-11-30 10:05:39
问题 I am trying to post an image (as part of a form) to a PHP server from a Worklight V6 app using the HTTP adapter. The image is base64 encoded navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 8, destinationType: navigator.camera.DestinationType.DATA_URL }); .. later in the code $('#myImageImg').attr('src', "data:image/jpeg;base64," + imageData); I send the image to the adapter var img = $('#myImageImg').attr('src'); var formData = {"someField" : name, "image" : img }; var

JS encodeURIComponent result different from the one created by FORM

家住魔仙堡 提交于 2019-11-30 09:55:52
问题 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=

XSLT version 1 URL encoding

女生的网名这么多〃 提交于 2019-11-30 08:00:26
问题 Is there a URL encoding function in XSLT version 1? I need something similar to encodeURIComponent function in javascript? Seeing as this is not possible as I'm using .NET platform as the XSLT is applied to a Sharepoint page. Is there a way to code this buy calling the javascript encode function within the XML, snippet below: <xsl:template name="BuildLink"> <xsl:param name="PrimarySubject" /> <xsl:text>?PrimarySubject=</xsl:text> <xsl:value-of select="$PrimarySubject" /> </xsl:template>

how to encode href attribute in HTML

荒凉一梦 提交于 2019-11-30 07:59:16
问题 What should be done against contents of href attribute: HTML or URL encoding? <a href="???">link text</a> On the one hand, since href attribute contains URL I should use URL encoding. On the other hand, I'm inserting this URL into HTML, so it must be HTML encoded. Please help me to overcome this contradiction. Thanks. EDIT: Here's the contradiction. Suppose there might be the '<' and '>' characters in the URL. URL encoding won't escape them, so there will be reserved HTML characters inside

Python urllib urlencode problem with æøå

元气小坏坏 提交于 2019-11-30 07:31:54
How can I urlencode a string with special chars æøå? ex. urllib.urlencode('http://www.test.com/q=testæøå') I get this error :(.. not a valid non-string sequence or mapping object You should pass dictionary to urlencode, not a string. See the correct example below: from urllib import urlencode print 'http://www.test.com/?' + urlencode({'q': 'testæøå'}) urlencode is intended to take a dictionary, for example: >>> q= u'\xe6\xf8\xe5' # u'æøå' >>> params= {'q': q.encode('utf-8')} >>> 'http://www.test.com/?'+urllib.urlencode(params) 'http://www.test.com/?q=%C3%A6%C3%B8%C3%A5' If you just want to URL

How to decode the url in php where url is encoded with encodeURIComponent()

被刻印的时光 ゝ 提交于 2019-11-30 06:31:21
问题 How to decode the url in php where url is encoded with encodeURIComponent()? I have tried the urldecode() but then also..i don't the url which i have encoded... I have to do this in php.. 回答1: You should use rawurldecode() . See the Manual 回答2: you can use this function: <?php $string = 'http%3A%2F%2Fexample.com'; $output = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($string)); echo html_entity_decode($output,null,'UTF-8'); ?> output will be : http://example.com 来源: https:/

Why doesn't decodeURI(“a+b”) == “a b”?

自作多情 提交于 2019-11-30 06:10:54
I'm trying to encode URLs in Ruby and decode them with Javascript. However, the plus character is giving me weird behavior. In Ruby: [Dev]> CGI.escape "a b" => "a+b" [Dev]> CGI.unescape "a+b" => "a b" So far so good. But what about Javascript? >>> encodeURI("a b") "a%20b" >>> decodeURI("a+b") "a+b" Basically I need a method of encoding / decoding URLs that works the same way in Javascript and Ruby. Edit: decodeURIComponent is no better: >>> encodeURIComponent("a b") "a%20b" >>> decodeURIComponent("a+b") "a+b" You might want to look at URI.encode and URI.decode : require 'uri' URI.encode('a + b

urllib.parse quote/unquate/urlencode

跟風遠走 提交于 2019-11-30 05:53:41
quote :url编码函数,将中文进行转化为%xxxx # _*_ coding::utf_8 _*_ import urllib.request import urllib.parse url='http://baidu.com/index.html?name=杨洪&pwd=123456' ret=urllib.parse.quote(url) ret1=urllib.parse.unquote(ret) print(ret) print(ret1) ##输出结果: http%3A//baidu.com/index.html%3Fname%3D%E6%9D%A8%E6%B4%AA%E8%BE%89%26pwd%3D123456 http://baidu.com/index.html?name=杨洪&pwd=123456 unquote:url解码函数,将%XXX转化为指定字符 urllencode:给定一个字典,将字典拼接为query_string,并且实现了编码功能 # _*_ coding::utf_8 _*_ import urllib.parse url='http://baidu.com/index.html' data={ 'name':'goudan', 'sex':'女', 'age':'18' } query_string=urllib.parse

Best way to get query string from a URL in python?

我只是一个虾纸丫 提交于 2019-11-30 05:46:52
I need to get the query string from this URL https://stackoverflow.com/questions/ask?next=1&value=3 and I don't want to use request.META . I have figured out that there are two more ways to get the query string: Using urlparse urlparse.urlparse(url).query Using url encode Use urlencode and pass the request.GET params dictionary into it to get the string representation. So which way is better? My colleagues prefer urlencode but have not provided a satisfying explanation. They claim that urlparse calls urlencode internally which is something I'm not sure about since urlencode lives in the urllib

URL Encode and Decode Special character in Java

喜欢而已 提交于 2019-11-30 04:53:13
In Java, I need to use HTTP Post to send request to server, but if in the parameter of the URL contains some special character it throws below Exception java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "&'" The code to send data DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(URL); String sessionId = RequestUtil.getRequest().getSession().getId(); String data = arg.getData().toString(); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair(param1,