views:

24

answers:

1

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?

+1  A: 

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.

nevan