views:

30

answers:

1

hi,

i have created a plist using .net environment and after the creation i set the encoding type as "iso-8859-1" in the plist encoding type. Then I tried to read it and show in the table view. The values are not as expected. It is having few characters which are of incorrect encoding type. What should i do ?

A: 

You could try to load the file as an NSString, which you could specify an encoding.

NSString* plistString = [NSString stringWithContentsOfURL:...
                                                 encoding:NSISOLatin1StringEncoding 
                                                    error:NULL];

and then use the -propertyList method to convert the string into a plist.

id plist = [plistString propertyList];

But it is better to ensure you always generate UTF-8/UTF-16 on the C# side.

KennyTM
@kennytm:thanks for the code. But i still face problems. I opened that plist file with xcode, it had the character like this "Sjö" but when i used your code and tried that out for uitableview or nslog it shows as "Sjö"what should i don ?
thndrkiss
@thndrkiss: `"ö"` = `c3 b6` in ASCII = `00f6` in UTF-8 = `"ö"`. Looks like the file is already in UTF-8.
KennyTM
great kenny. Excellent observation. I later found the same fact after a long time. thanks.
thndrkiss
You mean Latin-1/Windows-1252, not ASCII.
tc.