Valid characters for URI schemes?

孤人 提交于 2019-11-27 17:14:51

问题


I was thinking about Registering an Application to a URL Protocol and I'd like to know, what characters are allowed in a scheme?

Some examples:

  • h323 (has numbers)
    • h323:[<user>@]<host>[:<port>][;<parameters>]
  • z39.50r (has a . as well)
    • z39.50r://<host>[:<port>]/<database>?<docid>[;esn=<elementset>][;rs=<recordsyntax>]
  • paparazzi:http (has a :)
    • paparazzi:http:[//<host>[:[<port>][<transport>]]/

So, what characters can I fancy using?
Can we have...

  • @:TwitterUser
  • #:HashTag
  • $:CapitalStock
  • ?:ID-10T

...etc., as desired, or characters in the scheme are restricted by standard?


回答1:


According to RFC 2396, Appendix A:

  scheme        = alpha *( alpha | digit | "+" | "-" | "." )

Meaning:

The scheme should start with a letter (upper or lower case), and can contains letters (still upper and lower case), number, "+", "-" and ".".


Note: in the case of

paparazzi:http:[//<host>[:[<port>][<transport>]]/

the scheme is only the "paparazzi" part.




回答2:


The scheme according to RFC 3986 is defined as:

scheme      = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )

So the scheme must begin with an alphabetic character (AZ, az) and may be followed by any number of alphanumeric characters, +, -, or ..




回答3:


Quoth RFC 2396:

Scheme names consist of a sequence of characters beginning with a lower case letter and followed by any combination of lower case letters, digits, plus ("+"), period ("."), or hyphen ("-").



来源:https://stackoverflow.com/questions/3641722/valid-characters-for-uri-schemes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!