Many thanks for the explanation and clarification, much appreciated.

What's the best way of making the comparison in this situation, then, where the 
value returned by -characterAtIndex: is 16bit but the unicode character codes I 
want to check for are 24bit? I'm guessing it's not just as simple as casting 
the return value of -characterAtIndex: (e.g. (unsigned)[self 
characterAtIndex:index] or suchlike)?

Thanks again,
Keith

--- On Fri, 1/29/10, Graham Cox <[email protected]> wrote:

> From: Graham Cox <[email protected]>
> Subject: Re: NSXML and invalid UTF8 characters
> To: "Keith Blount" <[email protected]>
> Cc: [email protected]
> Date: Friday, January 29, 2010, 12:34 AM
> 
> 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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to