URL中片段标识符的有效字符列表? [英] List of valid characters for the fragment identifier in an URL?

查看:113
本文介绍了URL中片段标识符的有效字符列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用片段标识符在我的网络应用程序中为AJAX事件创建永久链接

I'm using the fragment identifier to create a permalink for AJAX events in my web app similar to this guy. Something like:

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

我已经做了很多搜索,但是找不到片段识别符的有效字符列表. W3C规范未提供任何内容.

I've done quite a bit of searching but can't find a list of valid characters for the fragment idenitifer. The W3C spec doesn't offer anything.

我是否需要将字符编码与通常的URL相同?

Do I need to encode the characters the same as the URL in has in general?

似乎在任何地方都没有很好的信息.

There doesn't seem to be any good information on this anywhere.

推荐答案

请参见 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]-._~:@/?

So you can use !, $, &, ', (, ), *, +, ,, ;, =, something matching %[0-9a-fA-F]{2}, something matching [a-zA-Z0-9], -, ., _, ~, :, @, /, and ?

这篇关于URL中片段标识符的有效字符列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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