WINAPI具有将Unicode主机名转换为Punycode的方法。Cocoa/Cocoa Touch是否有类似的机制?
发布于 2011-08-11 20:09:20
查看SBPunyCode (更新链接)
发布于 2011-09-22 17:00:36
这里有一个小技巧,它不需要任何外部库就可以工作。假设您在theUrl中有一个Unicode URL,您可以这样做:
NSURL *urlToLoad = nil;
NSPasteboard * pasteboard = [NSPasteboard pasteboardWithName:@"RandomPB"];
[pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
@try
{
if ([pasteboard setString:theUrl forType:NSStringPboardType])
urlToLoad = [WebView URLFromPasteboard:pasteboard];
}
@catch (NSException * exception)
{
urlToLoad = nil;
NSLog(@"Can't create URL from string '%@'.", theUrl);
}
return urlToLoad;https://stackoverflow.com/questions/7024933
复制相似问题