Should I code pluses in a URI URI?

In the URI, spaces can be encoded as + . Since this is so, should the leading plus be coded when creating custom URIs with an international prefix?

What's better? Both work in practice?

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

Not.

From Section 3 of RFC 3966 (URI for Phone Numbers):

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

You would only encode + percent if its part of the parameter value:

These characters are ["+", ";", "=" and "?" ] MUST be encoded as a percentage if they are displayed in the values ​​of the URI parameter.


Im not sure if leading + , which indicates that its global number , is considered a separator, but the definition of a global number says:

Globally unique numbers are identified by the leading β€œ+” character.

Therefore, it refers to + , not percent encoding.

And also examples make it clear that it should not be encoded in percent, for example:

 tel:+1-201-555-0123 

Note that spaces in tel URIs (for example, in parameter values) cannot be encoded with + . Using + instead of %20 for a space character is not something that can be done in any URI; its only possible in a URI whose URI scheme explicitly defines this.

+2
source

There are no conditions for encoding spaces in the tel: URI scheme - see RFC 3966 :

  5.1.1. Separators in Phone Numbers ... even though ITU-T E.123 [E.123] recommends the use of space characters as visual separators in printed telephone numbers, "tel" URIs MUST NOT use spaces in visual separators to avoid excessive escaping. 

A plus sign encodes a space only in application/x-www-form-urlencoded (the default content type for submitting a form is see W3C info re: forms ). There is no valid way to encode a space in a tel: URI URI. See Again RFC 3966 (page 5) for valid visual separators.

+1
source

All Articles