반응형

예를 들어서 아래와 같은 코드

NSString *xmlUrl = [NSString stringWithFormat:@"http://192.168.0.16:8181/coupon.do?method=iPhoneShopSrch&needLog=no&code=0301&srchText=강남"] ;

로 파싱을 시도할 때,

파라미터에 한글이 포함되어서 마지막에 "강남" <-이 녀석이 사실 %88%EB%8C%80%EC 대략 이런식으로 표현된다..

그래서 url에서 전혀 xml을 받아오지 못하는데...

해결책!

NSString *xmlUrl = [NSString stringWithFormat:@"http://192.168.0.16:8181/coupon.do?method=iPhoneShopSrch&needLog=no&code=0301&srchText=강남"] ;
NSString *escapedUrl = [xmlUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 

이렇게 해서 url을 escapedUrl 요놈으로 넘기면 해결!

Posted by npre
,