Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

URL Encoding



I am trying to figure out how to properly URL Encode Urls in Objective-C
Cocoa.
I know this has been discussed before, and doing a quick search, I came
across:

CFURLCreateStringByAddingPercentEscapes

with an example from here:

http://www.cocoabuilder.com/archive/message/cocoa/2001/12/16/16098

+(NSString *) urlencode: (NSString *) url

{


 NSString* out = [(NSString*)

CFURLCreateStringByAddingPercentEscapes(NULL,

(CFStringRef) url,

 NULL,

NULL, kCFStringEncodingUTF8)

autorelease];

 return out;

}


I have tried multiple examples of this, but it does not encode my URLs.

I ended up writing my own method to do this (which works):

http://mesh.typepad.com/blog/2007/10/url-encoding-wi.html#more

but I have this sneaking suspicion there is a better way.

So, how should I url encode urls within Cocoa?

thanks for any input / insight...

mike chambers
_______________________________________________

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:
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.