tags:

views:

826

answers:

2

Hi there

my app downloads and parses an xml file that contains German Umlauts (ä, ö, ü) and other special character (&, % etc). I seem to have a generall lack of understanding when it comes to encoding issues.

so what i do at the moment is:

  1. try to locate if i allready cached the xml file in my apps documents folder

1.a if the file exists i load it into a string

NSString * xmlData = [[NSString alloc] initWithContentsOfFile:filenameStr encoding:NSUTF8StringEncoding error:&error];

1.b if the file doesn't exist download its contents and save it afterwards

NSString *xmlData = [NSString stringWithContentsOfURL:urlRequest encoding:NSUTF8StringEncoding error:&err];
[xmlData writeToFile: filenameStr atomically: FALSE encoding:NSUTF8StringEncoding error:&error]
  1. afterwards (the data is loaded now) i want to parse it...

however, the contents of the xmlData is already "wrong" after stringWithContentsofURL returns (as i see it in the debugger). Also if i open the file that i saved into my documents folder, it's wrong too.

any advice, links, tips or best practices regarding encoding will be appreciated

thanks

sam

+1  A: 

Check the encoding of the xml and use it when initializing the string (see details here)

And because of

I seem to have a generall lack of understanding when it comes to encoding issues.

look here.

Kai
A: 

the file is not wrong its the encoding issue,

actually when contents are in some other language it is rendered in encoded form.

refer this question for help

http://stackoverflow.com/questions/2041238/xml-parsing-problem-in-iphone

Ankit Sachan