• 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: "So I want to connect to the internet in 2008..."
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "So I want to connect to the internet in 2008..."


  • Subject: Re: "So I want to connect to the internet in 2008..."
  • From: Jim Luther <email@hidden>
  • Date: Tue, 24 Jun 2008 09:09:07 -0700

On Jun 23, 2008, at 10:03 AM, Jens Alfke wrote:

That said, it's really easy to generate the right output. Looks like you already know the format. To do the correct encoding of the string contents you'll need to call [paramString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding].

You may find that - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding percent-escapes characters you don't want percent-escaped, or that it doesn't percent-escape characters you want percent-escaped. If that's the case, you'll need to drop down a layer and use CoreFoundation's CFURLCreateStringByAddingPercentEscapes() function. - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding calls CFURLCreateStringByAddingPercentEscapes() with the charactersToLeaveUnescaped and legalURLCharactersToBeEscaped parameters set to NULL.


You'll notice that the documentation for CFURLCreateStringByAddingPercentEscapes() says, "The characters escaped are all characters that are not legal URL characters (based on RFC 2396), plus any characters in legalURLCharactersToBeEscaped, less any characters in charactersToLeaveUnescaped." Since different parts of a URL have different rules for which characters are legal or not, you might wonder what characters are "legal URL characters". For that, you'll unfortunately have to look at the source code for CFURL at <http://www.opensource.apple.com/darwinsource/10.5.2/CF-476.10/CFURL.c > (you'll have to log in with your Apple ID to get there) and look at the isURLLegalCharacter() function.
Going the other direction, - (NSString *)stringByReplacingPercentEscapesUsingEncoding: (NSStringEncoding)encoding calls CFURLCreateStringByReplacingPercentEscapesUsingEncoding() with the charsToLeaveEscaped parameter set to CFSTR("") to request that all percent escapes be replaced. Again, if you don't like the default behavior, you can change it by using CFURLCreateStringByReplacingPercentEscapesUsingEncoding() and passing something different as the charsToLeaveEscaped parameter.
- Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >"So I want to connect to the internet in 2008..." (From: JP May <email@hidden>)
 >Re: "So I want to connect to the internet in 2008..." (From: JP May <email@hidden>)
 >Re: "So I want to connect to the internet in 2008..." (From: Mike Cohen <email@hidden>)
 >Re: "So I want to connect to the internet in 2008..." (From: JP May <email@hidden>)
 >Re: "So I want to connect to the internet in 2008..." (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: "So I want to connect to the internet in 2008..." / SUMMARY
  • Next by Date: Any knowledge base of router port-mapping support?
  • Previous by thread: Re: "So I want to connect to the internet in 2008..." / SUMMARY
  • Next by thread: Re: "So I want to connect to the internet in 2008..."
  • Index(es):
    • Date
    • Thread