• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSXML and invalid UTF8 characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSXML and invalid UTF8 characters


  • Subject: Re: NSXML and invalid UTF8 characters
  • From: Keith Blount <email@hidden>
  • Date: Fri, 29 Jan 2010 00:55:16 -0800 (PST)

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@hidden> wrote:

> From: Graham Cox <email@hidden>
> Subject: Re: NSXML and invalid UTF8 characters
> To: "Keith Blount" <email@hidden>
> Cc: email@hidden
> 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@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

References: 
 >Re: NSXML and invalid UTF8 characters (From: Graham Cox <email@hidden>)

  • Prev by Date: Node hierarchy with subclasses
  • Next by Date: ABNewPersonViewController and ABPersonViewController background color
  • Previous by thread: Re: NSXML and invalid UTF8 characters
  • Next by thread: Re: NSXML and invalid UTF8 characters
  • Index(es):
    • Date
    • Thread