|
From: | Richard Frith-Macdonald |
Subject: | Re: plists in UTF8 |
Date: | Wed, 14 Jun 2006 14:48:27 +0100 |
On 14 Jun 2006, at 14:21, Pete French wrote:
Well, if it has no BOM then how do you know it's UTF-8? For an XML plist you can theoretically use the initial header to determineIf it's XML then you are required to assume its UTF-8 unless you have indications to the contrary aren't you ? I thought that was part of the XML specification.
Yes it is, and if your program knows it's loading an XML file, it can explicitly put the data into a string using UTF-8 encoding.
... but property lists are commonly parsed from NSString objects loaded from file.
eg. plist = [[NSString stringWithContentsOfFile: aPath] propertyList]and in this sort of situation the initWithContentsOfFile: method doesn't know it's reading XML ... rather it has a well defined/ documented mechanism for determining what character encoding to use, which says it should look for BOMs and, in their absence, use the default encoding for the locale.
One good thing Apple is doing is to and new methods specifying encodings, and deprecate old methods which guess encoding based on locale ...
[Prev in Thread] | Current Thread | [Next in Thread] |