上下文:我正在创建一个将其数据存储在location.hash中的应用程序。我想尽可能少地编码字符以保持最大的易读性。
如this answer中所述,URL的每个段的保留字符都不同。那么URL Fragment / location.hash的限制是什么?
答案 0 :(得分:2)
根据RFC 3986: Uniform Resource Identifier (URI):
CREATE PROCEDURE [dbo].[spInsert]
@name nvarchar(128),
@Ret int Output
AS
BEGIN
insert into NameIdentifier
( Name, Identifier)
values
( @name, NEWID());
END
SET @Ret = @@IDENTITY
解压缩所有这些,并忽略百分比编码,我找到以下字符集:
fragment = *( pchar / "/" / "?" )
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
pct-encoded = "%" HEXDIG HEXDIG
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
虽然RFC does not mandate a particular encoding仅处理字符(不是字节),但根据Section 2.3 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~!$&'()*+,;=:@/?
仅表示ASCII,即拉丁字母的26个字母。因此,任何非ASCII字母都必须进行百分比编码。