Re: NSXML and invalid UTF8 characters
Re: NSXML and invalid UTF8 characters
- Subject: Re: NSXML and invalid UTF8 characters
- From: Graham Cox <email@hidden>
- Date: Fri, 29 Jan 2010 11:34:58 +1100
On 29/01/2010, at 11:29 AM, Keith Blount wrote:
> As an update, I tried this, which seems to partially work:
> - (NSString *)stringCleanedForXML // in an NSString category
{
unichar character;
> []
> Using this saved my XML strings in such a way as they didn't produce errors on loading, but this line:
>
> (character >= 0x10000 && character <= 0x10FFFF)
>
> Throws up this compiler warning:
>
> "Comparison is always false due (they mean "owing"... :) ) to limited range of data type."
>
> But I got these ranges from the XML site:
>
> http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char
>
> and based the above method on non-Cocoa code here:
>
> http://cse-mjmcl.cse.bris.ac.uk/blog/2007/02/14/1171465494443.html
>
> Obviously it's down to my misunderstanding though. So my questions are now:
> a) Why am I getting this error (i.e. what dunderheaded thing am I doing wrong)?
Because unichar is defined thus (NSString.h):
typedef unsigned short unichar;
Which only holds 16 bits. 0x10000 and 0x10FFFF are (at least) 20 bit constants.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden