1
간체 한자로 iTunes 검색 API를 사용하는 데 어려움을 겪고 있습니다. 문자를 인코딩하는 HTML과 함께 몇 가지 문자 변형 (Google 번역에서 제공)을 시도했습니다.Obj-C, iTunes 검색 쿼리에서 중국어 간체 인코딩?
아래 코드는 오류를 발생시키지 않지만 영어 단어와 달리 결과가 나에게주지 않습니다. 나는 또한 다른 중국어 단어를 시도했습니다.
그러나 진행 방법을 잘 모르겠습니다.
NSString *url_string = @"";
NSString *keyword = [@"Chéngfǎ" stringByReplacingOccurrencesOfString: @" "
withString: @"%20"];
//NSString *keyword = [@"乘法" stringByReplacingOccurrencesOfString: @" "
withString: @"%20"];
url_string = [NSString stringWithFormat:
@"https://itunes.apple.com/search?term=%@&country=%@&entity=software", keyword, @"cn"];
NSError *error;
NSData *data = [NSData dataWithContentsOfURL: [NSURL URLWithString: url_string]];
NSMutableArray *json;
if (data != nil)
{
json = [NSJSONSerialization JSONObjectWithData:data options: kNilOptions error: &error];
}
NSDictionary *outer = [json valueForKey: @"results"];
for(NSDictionary *item in outer)
{
//results
}
코드에 퍼센트 기호가 표시되어 있습니다. "% E4 % B9 % 98 % E6 % B3 % 95"에 "운하법"을 인코딩해야합니다. – GeneCode
@Jules이 효과가 있었습니까? – GeneCode
예 감사합니다. 수락했습니다. – Jules