NSURL URLWithString: is null with non-english accented characters

前端 未结 5 1366
孤独总比滥情好
孤独总比滥情好 2020-11-29 01:48

I have the following string...

NSString *googleSearchString = @\"http://www.google.com/search?q=lyrics+%22Tænder+På+Dig%22+%22Jakob+Sveistrup%22\";
         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 02:33

    You need to escape the special characters to make it work properly. Something like:

    [NSURL URLWithString:[googlSearchString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
    

提交回复
热议问题