I need to URLENCODE this:
<?php echo 'chart.php?api_url=http://0.chart.apis.google.com/chart?'.$chart1title.$chart1type.$chart1size.$chart1barsize.$chart1gridlines.$chart1data.$chart1color.$chart1bgcolor.$chart1visibleaxis.$chart1axislabels.$chart1axisdatascale.$chart1axisranges.'alt="answeredcalls"';?>
Run Code Online (Sandbox Code Playgroud)
And then decode it on the other side. How can I do this???
我正在使用http://validator.w3.org验证我的网站,并且&在我的链接描述文本中有一个问题.
这取自来源:
<a class='tag' href='/php/iphone software.php?function=developer&dev=witch%26wizards+inc.&store=143441'>witch&wizards inc.</a>
Run Code Online (Sandbox Code Playgroud)
这会在验证器中出现此错误:
第188行,第540列:无法生成一般实体"向导"的系统标识符
... 6wizards + inc.&store = 143441'> witch&wizards inc.
✉在文档中找到了实体引用,但没有定义该名称的引用
如果我对该描述进行了urlencode,那么验证就会通过,但是用户会看到文本显示为urlencoded,即
开发者女巫%26wizards + inc.
但是,如果显示未编码,即我认为它更加用户友好
开发者巫师和巫师公司
有没有办法通过验证,但仍然显示用户友好的文本?
它们之间的区别在于PHP urlencode编码空格+而不是%20?
对这两种语言执行相同操作的功能有哪些?
我的桌面应用程序必须从Internet下载文件.文件的路径是已知的,文件名本身是半变量的,即其他人将在那里放置新文件,我的应用程序将不得不下载它们.
现在我想确保URL是安全的,并且它将被正确解释.另外,如果文件名中有'#'(你永远不知道),我确实希望它被编码.Javascript有两个不同的功能:encodeURI和encodeURIComponent.后者还编码'#'字符,以及其他内容.当然,我可以自己动手,但我认为必须有功能准备就绪,我不妨做出一些旧的错误.
我将使用一个使用WinInet系列API函数(InternetOpen及其同类)的对象下载该文件.
所以我开始在MSDN上搜索,当然,还有UrlCanonicalize.但也有UrlEscape,CreateUri(但这不存在于Delphi 2010单元中),最后是InternetCreateUrl,它要求我拆分整个URL.我宁愿将URL的第一部分与URLEncoded文件名连接起来.
此外,它们都有大量不同的标志,不同的默认值在Windows版本的过程中发生了变化,我再也无法弄清楚它们之间的差异.有人知道哪一个最适合这个目的吗?
η的URL编码是%CE%B7.但在PHP中,我写作时会得到一些奇怪的符号echo urldecode("%ce%b7");
相反,如果我写,echo urlencode("?");那么我得到%26%23951%3B.为什么我不能使用%CE%B7?
解
问题是我们使用typo3.它有些如何不使用unicode进行内部处理.一旦我们设置$TYPO3_CONF_VARS['BE']['forceCharset'] = 'utf-8';错字3输出echo urldecode("%ce%b7");是正确的.
为什么echo urlencode("?");让我%26%23951%3B看到Joni的答案.
使用DOMDocument(),我正在替换a中的链接$message并添加一些东西,比如[@MERGEID].当我保存更改时$dom_document->saveHTML(),链接得到"排序"的url编码.[@MERGEID]成为%5B@MERGEID%5D.
稍后在我的代码中,我需要[@MERGEID]用ID 替换.所以我搜索urlencode('[@MERGEID]')- 但是,urlencode()将符号(@)的商业广告更改为%40,而saveHTML()则将其保留.所以没有比赛 - '%5B@MERGEID%5D' != '%5B%40MERGEID%5D'
现在,我知道可以运行str_replace('%40', '@', urlencode('[@MERGEID]'))以获得我在$ message中找到合并变量所需的内容.
我的问题是,DOMDocument使用什么RFC规范,为什么它与urlencode甚至rawurlencode不同?有什么我可以做的就是保存str_replace吗?
演示代码:
$message = '<a href="http://www.google.com?ref=abc" data-tag="thebottomlink">Google</a>';
$dom_document = new \DOMDocument();
libxml_use_internal_errors(true); //Supress content errors
$dom_document->loadHTML(mb_convert_encoding($message, 'HTML-ENTITIES', 'UTF-8'));
$elements = $dom_document->getElementsByTagName('a');
foreach($elements as $element) {
$link = $element->getAttribute('href'); //http://www.google.com?ref=abc
$tag = $element->getAttribute('data-tag'); //thebottomlink
if ($link) {
$newlink = 'http://www.example.com/click/[@MERGEID]?url=' . $link;
if ($tag) {
$newlink .= '&tag=' …Run Code Online (Sandbox Code Playgroud) 我正在尝试标准化我的网址中的邮件,而我正在使用URLEncoder.encode.我得到的问题是,输出似乎不是一个有效的网址.例如
val text = Some("test question (a) x (b) y").get
val query = "http://localhost:8080/ask?text=" + text
println(query)
val queryEnc = URLEncoder.encode(query, "UTF-8")
println(queryEnc)
Run Code Online (Sandbox Code Playgroud)
输出:
http://localhost:8080/ask?text=test question (a) x (b) y
http%3A%2F%2Flocalhost%3A8080%2Fask%3Ftext%3Dtest+question+%28a%29+x+%28b%29+y
Run Code Online (Sandbox Code Playgroud)
输出是否是有效的URL?(它看起来没有效果,因为我机器上的Chrome和Safari无法识别它).
我们正在使用Jersey Client 2.21。我注意到,当我们将花括号(也称为花括号)作为参数值时,则无法正确编码。不仅如此,大括号内的所有内容均未得到编码。对于常规括号或我测试过的其他不安全字符,情况并非如此。
请参见下面的示例。在此示例中,我输入三个参数。仅带有空格的控制参数。一种带花括号,另一种带方括号。
public static void testJerseyEncoding() {
Client client = ClientBuilder.newClient();
String url = "http://foo.com/path";
Map<String, String> map = new HashMap<>();
map.put("paramWithCurly", " {with a space}");
map.put("paramWithOutCurly", "with a space");
map.put("paramWithBracket", "[with a space]");
WebTarget target = client.target(url);
for (Map.Entry<String, String> entry : map.entrySet()) {
target = target.queryParam(entry.getKey(), entry.getValue());
}
System.out.println(target.toString());
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
JerseyWebTarget { http://foo.com/path?paramWithBracket=%5Bwith+a+space%5D¶mWithOutCurly=with+a+space¶mWithCurly=+{with a space} }
Run Code Online (Sandbox Code Playgroud)
泽西客户有问题吗?还是我错过了什么?花括号应已编码为“%7B”。
我正在尝试将生产就绪代码部署到Heroku进行测试。不幸的是,它没有获取JSON数据,因此我们将其转换为x-www-form-urlencoded。
params = urllib.parse.quote_plus(json.dumps({
'grant_type': 'X',
'username': 'Y',
'password': 'Z'
}))
r = requests.post(URL, data=params)
print(params)
Run Code Online (Sandbox Code Playgroud)
由于我猜测data=params格式不正确,因此该行显示错误。
有什么方法可以将urlencoded参数发布到API?
我正在尝试使用S3存储桶通过“静态Web托管重定向请求”执行http重定向。
我要重定向到的目标存储桶或域是:“ example.com/test?param1=123¶m2=456”,协议是“ https”。
但是,当我使用此设置并按了一下后,它最终将我重定向到:https : //example.com/test?param1=123¶m2=456/
有其他人通过这个工作吗?
redirect urlencode amazon-s3 special-characters amazon-web-services
urlencode ×10
php ×5
url-encoding ×3
java ×2
amazon-s3 ×1
api ×1
delphi ×1
delphi-2010 ×1
domdocument ×1
encode ×1
flask ×1
heroku ×1
javascript ×1
jersey-2.0 ×1
python ×1
redirect ×1
rfc ×1
scala ×1
typo3 ×1
unicode ×1
urldecode ×1
winapi ×1