测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | BSD |
发布最后发布 | 2017年9月 |
由 Jörg Bühmann,《a href="/owners/5814">Nate Weaver (Wevah) 维护。
v1.3 (2017)
by Nate Weaver (Wevah)
https://derailer.org/
https://github.com/Wevah/Punycode-Cocoa
这是一个简单的 punycode/IDNA 分类,基于 RFC 3492 和 RFC 3490 的代码和文档。
使用此功能可以在 Unicode 和 ASCII 之间转换国际化域名(IDN)。
要在您的项目中使用,您只需要 NSStringPunycodeAdditions.h/m
。此项目包含一个示例测试应用。
定义 PUNYCODE_COCOA_USE_WEBKIT
使 Punycode Cocoa 方法调用内部 WebKit 方法而不是自定义实现。如果您已经链接到 WebKit 或需要额外的同音攻击保护,则非常有用。然而,由于其使用私有方法,这可能在 App Store 上不被允许。
@property (readonly, copy, nullable) NSString *punycodeEncodedString;
@property (readonly, copy, nullable) NSString *punycodeDecodedString;
将字符串编码或解码为其 punycode 编码的格式,删除变体选择器(U+FE00
-U+FE0F
)。
@property (readonly, copy, nullable) NSString *IDNAEncodedString;
如果 self
包含非 ASCII,则调用 -punycodeEncodedString
并在前面加上 xn--
。
@property (readonly, copy, nullable) NSString *IDNADecodedString;
解码由 -IDNAEncodedString
返回的字符串。
@property (readonly, copy, nullable) NSString *encodedURLString;
@property (readonly, copy, nullable) NSString *decodedURLString;
对 URL 字符串中每个合适的部分(域名位)执行编码/解码操作。
+ (nullable instancetype)URLWithUnicodeString:(NSString *)URLString;
等同于 [NSURL URLWithString:URLString.encodedURLString]
的便利方法。
@property (readonly, copy, nullable) NSString *decodedURLString;
等同于 anURL.absoluteString.decodedURLString
的便利属性。
© 2012–2017 Nate Weaver (Wevah)