Percent Encoding Url Components
Subject : Percent Encoding Url Components
From: "John Cassington" <email@hidden >
Date: Fri, 27 Apr 2007 06:58:01 +1000
Delivered-to: email@hidden
Delivered-to: email@hidden
Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; b=iYjDbxF/47oCO6QGhAqTsIuFc/kpiGsBvYEevgRp599jus083Z+niIw12qIdS3ITVWNiQyGrI7JljnaK9nP1KSInk/PRo0u36Tjk5/TI4NKbt5xAB4hOG+KZFMB1GIjDqKQM32xjZM1tJ0frW6WZbTAju3IvyOLjHFNjJw3HnqQ=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=Q2PCiM0od8hVCLMt2NMw3dfwHpzZ139BZJqmzRRanRvvmN7U0Nq5+qBvHYDtsopeDYBf0DoQlYom9vMVsLCtPbTvW2ICG8EauddPTd8u4GL1z5HOd+8rodjoOsM3b1JePuwnGkqiOq853Ig+dw97Ys7neao3X489+2rR2JBd2HY=
Hi, I have a string containing a URL address which itself has a URL
component as shown:
http://www.google.com/search?q=COMPONENT
This component is simply an NSString
<http://cocoadev.com/index.pl?NSString >which i need to percent escape
before posting. An example of the components
contents is as follows:
'cocoadev rocks!'
I have attempted to replace the space and exclamation mark with their
respective percent-escaped values, %20 and %21 respectively.
Here is my code so far, which has not been working:
- (NSString <http://cocoadev.com/index.pl?NSString >
*)urlEncodeValue:(NSString <http://cocoadev.com/index.pl?NSString >
*)string {
CFStringRef <http://cocoadev.com/index.pl?CFStringRef >
originalURLString = (CFStringRef
<http://cocoadev.com/index.pl?CFStringRef >)string;
CFStringRef <http://cocoadev.com/index.pl?CFStringRef >
preprocessedString =
CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
originalURLString, CFSTR(""), kCFStringEncodingUTF8);
CFStringRef <http://cocoadev.com/index.pl?CFStringRef > urlString =
CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
preprocessedString, NULL, NULL, kCFStringEncodingUTF8);
return (NSString <http://cocoadev.com/index.pl?NSString > *)urlString;
}
I have also tried the following
- (NSString <http://cocoadev.com/index.pl?NSString >
*)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding
but that method doesn't seem to encode all values, such as ! and + etc.
any ideas as to why this isn't working
thanks,
john
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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/email@hidden
This email sent to email@hidden
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.