3

I have the same exact problem that's in this question, but it didn't get any good answers.

I'm trying to parse an XML file with an ISO-8859-1 encoding, but everytime there's an accentuated word, it gets truncated and doesn't show properly.

Example: 

Original Word: Interés 

Word Shown: és
Community
  • 1
  • 1
  • If that question didn't receive enough attention, feel free to add a comment to it, requesting further expansion on it. – Nightfirecat Nov 15 '11 at 00:09
  • possible duplicate of [Problemas com Parse XML - Iphone](http://stackoverflow.com/questions/5070237/problemas-com-parse-xml-iphone) – bta Nov 15 '11 at 18:08
  • do you receive an answer for this question? –  Feb 06 '12 at 06:40

2 Answers2

1

You must use a NSMutableString and append chars with it on the foundCharacters method. That's why your string becomes truncated.

Carlos Ricardo
  • 2,058
  • 25
  • 32
1

You're making the assumption that you only get one -parser:foundCharacters: delegate method for the text. In this case, that's wrong. You're getting two calls to -parser:foundCharacters:, the first being the text up to the accented character, and the second being the text after it. Your logs even demonstrate this.

Therefore, what you need to do is, when you start a new element, you should also initialize a new NSMutableString* instance. Then when you get -parser:foundCharacters: you append to this string instead of replacing it. When the tag closes, this string now contains all of the text in the tag, instead of just the last text block.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347