电话URI中的加号是否应该编码? [英] Should the plus in tel URIs be encoded?

查看:180
本文介绍了电话URI中的加号是否应该编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在URI中,空格可以编码为+.既然是这种情况,那么在创建带有国际前缀的电话URI时是否应该对前导加号进行编码?

In a URI, spaces can be encoded as +. Since this is the case, should the leading plus be encoded when creating tel URIs with international prefix?

哪个更好?两者都在实践中起作用吗?

Which is better? Do both work in practice?

<a href="tel:+1234">Call me</a>
<a href="tel:%2B1234">Call me</a>

推荐答案

否.

来自RFC 3966的第3 部分(电话号码):

From section 3 of RFC 3966 (The tel URI for Telephone Numbers):

如果保留字符为"+",;","=和?"用作"tel" URI组件之间的定界符,不得对它们进行百分比编码.

If the reserved characters "+", ";", "=", and "?" are used as delimiters between components of the "tel" URI, they MUST NOT be percent encoded.

如果+是参数值的一部分,则只能对其进行百分比编码:

You would only percent-encode a + if it’s part of a parameter value:

如果这些字符["+",;","="和?"]出现在tel URI参数值中,则必须按百分比进行编码.

These characters ["+", ";", "=", and "?"] MUST be percent encoded if they appear in tel URI parameter values.


我不确定前导+是否表示它是全局数字,算作定界符,但全局数字的定义为:


I’m not sure if the leading +, which indicates that it’s a global number, counts as delimiter, but the definition of a global number says:

全球唯一的数字由前导"+"字符标识.

Globally unique numbers are identified by the leading "+" character.

因此它指的是+,而不是百分比编码的东西.

So it refers to +, not to something percent-encoded.

示例明确指出,这不应该是百分比-编码,例如:

And also the examples make clear that it’s not supposed to be percent-encoded, e.g.:

tel:+1-201-555-0123


请注意,tel URI中的空格(例如,参数值中的空格)可能未使用+进行编码.在任何URI中都不能使用+代替%20作为空格字符.只有在其URI方案明确定义了URI的URI中才有可能.


Note that spaces in tel URIs (e.g., in parameter values) may not be encoded with a +. Using + instead of %20 for a space character is not something that may be done in any URI; it’s only possible in URIs whose URI scheme explicitly defines that.

这篇关于电话URI中的加号是否应该编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆