2012-12-28 2 views
0

일부 텍스트가 UITextView에 올바르게 표시되지 않습니다. 은 "é", "C"와 "N"등 ...이 모든 같이 표시되는 : 웹 브라우저에서 볼 때UITextView에서 외국어 텍스트를 올바르게 표시하는 방법

enter image description here

텍스트는 서버와 고급 디스플레이에서오고있다.

궁금한 점이 있으신가요? 어떤 도움을 주셔서 감사합니다.

// the deal id is passed from the offersvc table selected item and into the url 
    // dealID is 1020414 

    NSString *jsonDealString = [NSString stringWithFormat:@"http://api.**********.net/v1/public/details?id=%@&yd.key=******", dealId]; 

    NSLog(@"jsondealstring is %@", jsonDealString); 

    // NSLog(@"deal id is %@",dealId); 

    // Download JSON 
    NSString *jsonString = [NSString 
          stringWithContentsOfURL:[NSURL URLWithString:jsonDealString] 
          encoding:NSStringEncodingConversionAllowLossy 
          error:nil]; 

    // Create parser for the api 
    SBJSON *parser = [[SBJSON alloc] init]; 
    NSDictionary *results = [parser objectWithString:jsonString error:nil]; 

    [self setDisplayItems:[results objectForKey:@"results"]]; 

    NSDictionary *item = (NSDictionary *)[displayItems objectAtIndex:0]; 

// NSLog(@"item from details is %@", item); 

    // set the labels and text views. 

    link = [item objectForKey:@"link"]; 
    catStr = [item objectForKey:@"cat"]; 
    vendorStr = [item objectForKey:@"vendor"]; 
    titleStr = [item objectForKey:@"main_tag"]; 
+0

우리는 당신이 UITextView에 텍스트를 얻는 방법의 코드를 볼 수 다음과 같은 추가? –

+0

@PeterPajchl 텍스트보기로 텍스트를 가져 오기 위해 사용하는 코드를 추가했습니다. 감사합니다 :) – hanumanDev

답변

1

당신은 UTF-8 인코딩을 설정해야합니다

여기에 코드입니다. 수정 된 질문

의 응답

편집 간단히 NSUTF8StringEncoding

NSString *jsonString = [NSString 
         stringWithContentsOfURL:[NSURL URLWithString:jsonDealString] 
         encoding:NSStringEncodingConversionAllowLossy|NSUTF8StringEncoding 
         error:nil]; 
+0

나는 UTF - 8 인코딩을 시도하고 문자가 여전히 잘못 표시됩니다. 감사 – hanumanDev

관련 문제