2013-05-22 3 views
0

NSMutableDictionary를 만들고 내 웹 사이트에서 쿼리 한 포럼 게시물로 채 웁니다. 슈퍼 간단한 코드, 아무것도하지만 ...특정 문자가 포함 된 경우 NSMutableDictionary가 초기화되지 않습니다.

_postBodies = [[NSMutableDictionary alloc] initWithContentsOfURL:[NSURL URLWithString:urlBodiesSource]]; 

...는 PHP/MySQL을 생성 PLIST 파일에서 당겨, 그것은 일반적으로 잘 작동합니다. 즉, 게시물 중 일부가 영어 이외의 문자 또는 HTML 기호와 같은 특정 문자를 포함하면 전체가 모두 초기화되지 않습니다. 나는 그것을 디버거에서 줄 단위로 추적 해 왔으며, 소스 파일에서 34 개의 게시물 (또는 무엇이든)이 작동하는 것을 그대로 볼 수 있지만 plist에 이상한 문자가있는 35 번째 게시물을 추가하면 모든 것이 실패합니다. 초기화합니다.

이 방법이 있습니까? NSMutableDictionary에 문제가되는 문자를 제거하거나 이스케이프 처리하는 방법은 무엇입니까? 아니면 그들이 아마도 내 plist 파일을 트리핑 수 있으며, 사전 잘 작동합니까?

예를 들어, this plist source file을 확인하십시오. 3 개의 게시물 만 있고 마지막 하나가 문제입니다. 그 게시물을 제외하고 모든 것이 작동합니다. 그것을 포함하면 NSMutableDictionary가 전혀 채워지지 않습니다. 그것은 꽤 정상적인 것 같습니다. 단 몇 개의 탭과 그 위에 circumflex가있는 몇 개의 O가 있습니다.

<key>2</key> 
<string>Wow, SquattingB. I know I'm melodramatic, but what's with you? lol. Yeah, it's a shame that all the cool people congregated here just to watch the codex, only to have the series end and leave everyone dumbstruck as to what to do. (It was that good, nothing else has the same appeal) Hopefully this forum will remain as cool as it has been up to the point when the creators get out of college. Then maybe we can see whether they have awesome news of what is next for the series and the forum or if they just boot us back to HBO. lol.But what is a forum?Dictionary forum |?fôr?m| noun (pl. forums) 1 a place, meeting, or medium where ideas and views on a particular issue can be exchanged : it will be a forum for consumers to exchange their views on medical research. 2 a court or tribunal. 3 (pl. fora |?fôr?|) (in an ancient Roman city) a public square or marketplace used for judicial and other business. ORIGIN late Middle English (sense 3) : from Latin, literally ‘what is out of doors,’ originally denoting an enclosure surrounding a house; related to fores ‘(outside) door.’ Sense 1 dates from the mid 18th cent.That's what I thought. So the people are what make it great, yes? And I'm sure the patrons aren't leaving anytime soon, so we're in pretty good standing as to what will become of the forum. For now, anyway.</string> 

경험이 있으신 분들이나 조언을 구할 수있는 사람이 있습니까? 나는 이제 막 시작된 ​​간단한 솔루션을 높이 평가할 것이지만, 당신이 제공 할 수있는 통찰력을 좋아할 것입니다!

답변

0

PList 텍스트 인코딩을 확인하고 있습니까? iOS 프로그래밍은 UTF-8로 수행됩니다.

나는 (PHP 태그로 질문을 표시 했으므로) 검색하는 URL이 PHP에서 작동한다고 가정합니다. utf8_encode()을 사용하여 텍스트 인코딩을 시도 했습니까?

또 다른 방법으로 JSON을 사용할 수 있습니다. PHP의 json_encode()은 자동으로 이상한 문자를 UTF-8 16 진수 표현 (\ x {NUMBER})으로 변환합니다. 또한 htmlspecialchars()을 사용해보세요.

행운을 빈다.

+0

** utf8_encode() **가 효과가있는 것 같습니다. 감사! – Nerrolken

관련 문제