NSURL with special characters

后端 未结 3 696
礼貌的吻别
礼貌的吻别 2021-01-18 01:30

How can I encode this url to be displayed in a UIWebview:

http://de.wikipedia.org/?search=Bevölkerungsentwicklung

I tried:

-stringByAddingPer         


        
3条回答
  •  梦毁少年i
    2021-01-18 02:12

    I found also that for some North European characters, NSISOLatin1StringEncoding fits better. This one gives me a better result

    - (void) testEncoding {
        NSString * urlString = @"http://example/path/fileName_blå.pdf";
        urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSISOLatin1StringEncoding];
        NSURL * url = [NSURL URLWithString:urlString];
        NSLog(@"URL: %@", url);
    }
    

提交回复
热议问题