URL中片段标识符的有效字符列表?

我正在使用片段标识符为我的networking应用中的AJAX事件创build一个永久链接类似于这个家伙 。 就像是:

http://www.myapp.com/calendar#filter:year/2010/month/5 

我已经做了相当多的search,但无法find片段标识符的有效字符列表。 W3C规范不提供任何东西。

我是否需要对字符进行编码,与一般的URL相同?

在这个地方似乎没有任何好的信息。

请参阅RFC 3986 。

 fragment = *( pchar / "/" / "?" ) pchar = unreserved / pct-encoded / sub-delims / ":" / "@" unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" pct-encoded = "%" HEXDIG HEXDIG sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" 

所以你可以使用!$&'()*+ ;= ,匹配%[0-9a-fA-F]{2}东西,匹配[a-zA-Z0-9]-._~:@/?

http://tools.ietf.org/html/rfc3986#section-3.5

 fragment = *( pchar / "/" / "?" ) 

 pchar = unreserved / pct-encoded / sub-delims / ":" / "@" unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" pct-encoded = "%" HEXDIG HEXDIG 

因此,根据RFC,片段不能包含# ,原始%^[]{}\"<>

另一个RFC就是这样说的: RFC-1738

 URL schemeparts for ip based protocols: HTTP httpurl = "http://" hostport [ "/" hpath [ "?" search ]] hpath = hsegment *[ "/" hsegment ] hsegment = *[ uchar | ";" | ":" | "@" | "&" | "=" ] search = *[ uchar | ";" | ":" | "@" | "&" | "=" ]