문제

I am trying to use UIWebView to load a Chinese web url. If I encode it with utf-8 then it becomes:

html/libfunctions/%CA%FD%D7%E9%B9%DC%C0%ED(Array).htm -- xchm://03000000-0A00-0400-F25E-D84B09001600/ which cannot be loaded from UIWebView.

If I try to put it using the default one of Chinese: html/libfunctions/录脝脢卤脝梅鹿脺脌铆(Timers).htm, then the

NSString *urlString = @"html/libfunctions/录脝脢卤脝梅鹿脺脌铆(Timers).htm";
NSURL *url = [NSURL URLWithString:urlString];

will give me a nil url. Does anybody know how can I load a Chinese web url?

도움이 되었습니까?

해결책

Have you tried using -stringByAddingPercentEscapesUsingEncoding:? Pass it the encoding for the string and it should give you a valid URL which will change to Chinese characters when transferred to a broswer.

EDIT: Use that function only on the Chinese part of your url, then concatenate the "http://www." part.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top