encodeuricomponent

encodeURIComponent behaves differently in browsers for china as location

烂漫一生 提交于 2019-12-05 14:54:19
i have an interesting problem in hand that involves chinese.. i use google custom search and append searched keywords as below.. window.location="http://search.xyz.com/search/cn/zh"+"#"+encodeURIComponent(searchedKeywords); results in chrome and internet explorer for 搜索 are proper but in firefox no results appear.. in chrome and internet explorer, url created is http://search.xyz.com/search/cn/zh#%E6%90%9C%E7%B4%A2 in firefox, url created is http://search.xyz.com/search/cn/zh#%u641C%u7D22 in chrome and internet explorer, search box that appears in the result page has value æç´¢ in firefox,

How to encode URL parameters?

元气小坏坏 提交于 2019-12-03 19:15:38
问题 I am trying to pass parameters to a URL which looks like this: http://www.foobar.com/foo?imageurl= and I want to pass the parameters suchas and image URL which is generated itself by another API, and the link for the image turns out as: http://www.image.com/?username=unknown&password=unknown However, when I try to use the URL: http://www.foobar.com/foo?imageurl=http://www.image.com/?username=unknown&password=unknown it doesn't work.. I have also tried using encodeURI and encodeURIComponents

encodeURI与encodeURIComponent

£可爱£侵袭症+ 提交于 2019-12-03 07:23:40
js对url进行编码涉及3个函数:escape,encodeURI,encodeURIComponent, 相应3个解码函数:unescape,decodeURI,decodeURIComponent 1、encodeURIComponent encodeURIComponent() is a global function that returns an encoded copy of its s argument. ASCII letters and digits are not encoded, nor are the following ASCII punctuation characters: - _ . ! ~ * ' ( ) All other characters, including punctuation characters such as /, :, and # that serve to separate the various components of a URI, are replaced with one or more hexadecimal escape sequences. Note the difference between encodeURIComponent() and encodeURI(): encodeURIComponent(

js escape, encodeURI, encodeURIComponent

痴心易碎 提交于 2019-12-03 07:23:16
escape, encodeURI, encodeURIComponent 1)基本介绍 js 对文字进行编码涉及3个函数:escape,encodeURI,encodeURIComponent, 相应3个解码函数: decodeURI,decodeURIComponent 2)用途 1、 传递参数时需要使用encodeURIComponent,这样组合的url才不会被#等特殊字符截断。 例如:"http://www.baidu.com?name="+encodeURIComponent(value); 2、 进行url跳转时可以整体使用encodeURI 例如:Location.href="/encodeURI"("http://cang.baidu.com/do/s?word=百度&ct=21"); 3、 js使用数据时可以使用escape 例如:对数据简单的操作时。 4、 escape对0-255以外的unicode值进行编码时输出%u****格式,其它情况下escape,encodeURI,encodeURIComponent编码结果相同。 3)区别 1、 encodeURIComponent 将文本字符串编码为一个统一资源标识符 (URI) 的一个有效组件。他会将URL的路径分隔符也编码,所以,他只适合编码参数的值 2、 encodeURI 返回编码为有效的统一资源标识符

怎样设置默认打印机(HttpPrinter 易桥网络打印机)

匿名 (未验证) 提交于 2019-12-02 23:35:02
怎样设置默认打印机(HttpPrinter 易桥网络打印机) 1.把 报表绑定打印机 2.客户端打印时 指定打印机, 控制面板中 可以查看您的 打印机的名称 下面的 "PrinterName": encodeURIComponent("打印机名称"), 改为 "PrinterName": encodeURIComponent("EPSON LQ-630K ESC/P2") { "ReportName": encodeURIComponent("test.grf"), / 报表文件名 / "Copies": 1, / 可选。打印份数,支持指定打印份数。默认1份,如果为零,不打印,只返回报表生成的pdf,jpg等文件 / "PrinterName": encodeURIComponent("打印机名称"), / 可选。指定打印机,为空的话 使用默认打印机, 请在 控制面板 -> 设备和打印机 中查看您的打印机的名称 / "PrintOffsetX": 0, / 可选。打印右偏移,单位厘米。报表的水平方向上的偏移量,向右为正,向左为负。 / "PrintOffsetY": 0, / 可选。打印下偏移,单位厘米。 报表的垂直方向上的偏移量,向下为正,向上为负。 / "token": encodeURIComponent("aa"), /*可选。只要token值在列表中 方可打印

url传参参数编码解码问题

匿名 (未验证) 提交于 2019-12-02 23:34:01
JS中encodeURIComponent(URL)编码与decodeURIComponent(URL)解码详解 (1) encodeURIComponent(url) 函数 定义和用法 encodeURIComponent() 函数可把字符串作为 URI 组件进行编码。 语法 encodeURIComponent(参数URIstring ) 参数 描述 URIstring 必需。一个字符串,含有 URI 组件或其他要编码的文本(中文或者网址)。 返回值 URIstring 的副本,其中的某些字符将被十六进制的转义序列进行替换。 说明 该方法不会对 ASCII 字母和数字进行编码,也不会对这些 ASCII 标点符号进行编码: - _ . ! ~ * ' ( ) 。 其他字符(比如 :;/?:@&=+$,# 这些用于分隔 URI 组件的标点符号),都是由一个或多个十六进制的转义序 列替换的。 (1) decodeURIComponent(url) 函数 定义和用法 decodeURIComponent() 函数可把字符串作为 URI 组件进行解码。 语法 decodeURIComponent(参数URIstring ) 参数 描述 URIstring 必需。一个字符串,含有 URI 组件或其他要解码的文本。 返回值 URIstring 的副本

javascript的encodeURIComponent

匿名 (未验证) 提交于 2019-12-02 21:40:25
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zyh_haha/article/details/90517071 本系列文章是本人学习相关知识时所积累的笔记,以记录自己的学习历程,也为了方便回顾知识;故文章内容较为随意简练,抱着学习目的来的同学务必转移他处,以免我误人子弟~ 参考资料: MDN:encodeURIComponent 工作中碰到问题: 某个元素的 background-image 的值 url() 中的值是经过 encodeURIComponent 处理的图片路径;如果图片路径中包含着英文括号 () 则 encodeURIComponent 无法将英文括号转义,即 好123(2).jpg 只能变成 %E5%A5%BD123(2).jpg 问题就在于这样的话图片路径被当成非法的,导致图片无法在浏览器中显示 查看了 MDN 文档才知道,encodeURIComponent 会忽略 字母、数字、(、)、.、!、~、*、'、-和_ ,所以给出一个较为安全的办法: function fixedEncodeURIComponent ( str ) { return encodeURIComponent ( str ) . replace ( /[!'()*]/g , function ( c ) { return '%' + c

Javascript Query String Parsing

老子叫甜甜 提交于 2019-12-01 18:20:50
1. URL encoding 为什么要进行URL encoding?这是因为,有些字符是不能成为URL一部分的,举个例子,比如空格符。另外,有些有特殊含义的保留字符,比如#,作为HTML锚点,用于定位到HTML文档的某个位置上;=符号在URL里用于分割URL参数的key和value。 URL encoding依据以下规则: 字母(A–Z 以及 a–z),数字(0-9)以及'.','-','~'和'_'这些字符不进行编码 空格符要编码成+或者"%20" 所有其他的字符,要被编码成%HH这样形式的 十六进制 表示;任何非ASCII字符,应该要取UTF-8的十六进制(或者是其他编码),以%HH表示; NOTE: 更多详细信息,可以参考这篇WIKI—— Query String 。关于空格符以及其他的保留字符,可以去查阅标准文档 RFC 1738 。 2. Javascript Encode/Decode Functions Javascript内置了几对编码和解码的函数。起初只有escape和unescape这一对方法,但后来这对方法已经不推荐使用了,新的标准制定了两对新的编码和解码函数:encodeURI和decodeURI以及encodeURIComponent和decodeURIComponent。 但实际上内置的编码解码函数,对于URL query

how can I javascript decodeURI in PHP?

若如初见. 提交于 2019-11-30 21:56:21
I have a javascript which sends some specific information to a PHP api . Before to send it performs encodeURI . How can I "decode" it in PHP ? I understand that urldecode/urlencode is different that javascript encode/decodeURI so what can I use ? Unless you've encoded it multiple times (e.g. by explicitly calling the encode method AND inserting the value into a form field which is then submitted) you don't need to do anything - it is transparently converted back to its original form when the request is parsed. Use encodeURIComponent in Javascript: http://www.w3schools.com/jsref/jsref

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=