Re: "So I want to connect to the internet in 2008..."
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