• 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: Thu, 28 Jan 2010 15:47:12 -0800 (PST)

Many thanks for your reply. Wouldn't using these methods be a lot more expensive (and slower) than going through using -characterAtIndex: or something similar, accessing the characters directly, though? I'm thinking that I would have to add every character to the character set and then let NSString deal with all the underlying character stuff this way, whereas if I could check the unicode char is within a range then it would be faster. I could be entirely wrong though, which is why I'm asking. :)

Thanks again and all the best,
Keith

--- On Thu, 1/28/10, Jens Alfke <email@hidden> wrote:

> From: Jens Alfke <email@hidden>
> Subject: Re: NSXML and invalid UTF8 characters
> To: "Keith Blount" <email@hidden>
> Cc: email@hidden
> Date: Thursday, January 28, 2010, 11:40 PM
>
> On Jan 28, 2010, at 3:16 PM, Keith Blount wrote:
>
> > So, my question is, what is the best way for me to
> filter out these invalid characters from my NSString before
> I pass it into NSXMLElement's -initWithName:stringValue: or
> similar methods, to avoid creating XML documents that won't
> open?
>
>
> Make an NSCharacterSet containing the 'bad' characters.
> Make a mutable copy of the string.
> Use -[NSString rangeOfCharactersFromSet:options:range:] to
> iterate through the string finding the 'bad' characters.
> Delete each bad character from the mutable string as you
> find it.
>
> If there are only a handful of bad characters, it might be
> more straightforward to use NSMutableString's
> replaceOccurrencesOfString:withString:options:] method
> instead to delete them one at a time.
>
> —Jens



_______________________________________________

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

  • Follow-Ups:
    • Re: NSXML and invalid UTF8 characters
      • From: Jens Alfke <email@hidden>
References: 
 >Re: NSXML and invalid UTF8 characters (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: NSXML and invalid UTF8 characters
  • Next by Date: mouseEntered/-mouseExited not firing on drag (NSTrackingEnabledDuringMouseDrag on)
  • Previous by thread: Re: NSXML and invalid UTF8 characters
  • Next by thread: Re: NSXML and invalid UTF8 characters
  • Index(es):
    • Date
    • Thread