检索非英文字符的URL

时间:2012-11-20 08:34:48

标签: ios utf-8 nsstring nsurl url-scheme

我想从短信(网址方案)打开应用。例如,如果有人向我发送文本“myapp:// abcd”,我可以使用safari打开此URL并使用[url host]打开具有abcd值的应用程序。但问题是,如果不是英语?例如“myapp://สวัสดี”(泰语)或“myapp://おはよう”(日语),我用xn - l3c1bib8a0a而不是“สวัสดี”打开应用程序。

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test" 
                                                    message:[url host] 
                                                   delegate:self 
                                          cancelButtonTitle:@"OK" 
                                          otherButtonTitles:nil];
    [alert show];
    [alert release];
    return YES;
}

提前致谢。

1 个答案:

答案 0 :(得分:0)

SMS字符集是7位且有点特殊,所以看起来您的服务提供商正在将国际网址翻译为他们的punycode(http://en.wikipedia.org/wiki/Punycode)等价物......