<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: iPhone tip #1 &#8211; URL encoding in Objective-C</title>
	<atom:link href="http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/</link>
	<description>Yet another developer blog</description>
	<lastBuildDate>Mon, 19 Dec 2011 21:48:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: antony</title>
		<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/comment-page-1/#comment-357</link>
		<dc:creator>antony</dc:creator>
		<pubDate>Tue, 15 Feb 2011 08:46:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=100#comment-357</guid>
		<description>It is very helpful to me</description>
		<content:encoded><![CDATA[<p>It is very helpful to me</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: antony</title>
		<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/comment-page-1/#comment-352</link>
		<dc:creator>antony</dc:creator>
		<pubDate>Wed, 12 Jan 2011 04:57:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=100#comment-352</guid>
		<description>Good one it is the simple step url encoding technique.. you are great !!!</description>
		<content:encoded><![CDATA[<p>Good one it is the simple step url encoding technique.. you are great !!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benjie</title>
		<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/comment-page-1/#comment-316</link>
		<dc:creator>Benjie</dc:creator>
		<pubDate>Thu, 23 Sep 2010 14:09:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=100#comment-316</guid>
		<description>Thanks, I hate wading through documentation for this stuff. Personally, I&#039;ve made it an instance method rather than a class method:

@implementation NSString (url) 
-(NSString *)urlEncodedString {
	return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR(&quot;:/?#[]@!$&amp;’()*+,;=&quot;), kCFStringEncodingUTF8) autorelease];
}
-(NSString *)urlDecodedString {
	return [self stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
@end

e.g. NSString *urlEncodedGoogle = [@&quot;http://www.google.com/&quot; urlEncodedString];</description>
		<content:encoded><![CDATA[<p>Thanks, I hate wading through documentation for this stuff. Personally, I&#8217;ve made it an instance method rather than a class method:</p>
<p>@implementation NSString (url)<br />
-(NSString *)urlEncodedString {<br />
	return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR(":/?#[]@!$&amp;’()*+,;=&#8221;), kCFStringEncodingUTF8) autorelease];<br />
}<br />
-(NSString *)urlDecodedString {<br />
	return [self stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];<br />
}<br />
@end</p>
<p>e.g. NSString *urlEncodedGoogle = [@"http://www.google.com/" urlEncodedString];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Beto</title>
		<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/comment-page-1/#comment-314</link>
		<dc:creator>Beto</dc:creator>
		<pubDate>Fri, 23 Jul 2010 14:28:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=100#comment-314</guid>
		<description>t’s very easy to URL Encode an NSString in Objective-C (i.e. make a string safe to send using a GET request).  Simply do this:

NSString* escapedUrlString =
   [unescapedString stringByAddingPercentEscapesUsingEncoding:
                        NSASCIIStringEncoding];</description>
		<content:encoded><![CDATA[<p>t’s very easy to URL Encode an NSString in Objective-C (i.e. make a string safe to send using a GET request).  Simply do this:</p>
<p>NSString* escapedUrlString =<br />
   [unescapedString stringByAddingPercentEscapesUsingEncoding:<br />
                        NSASCIIStringEncoding];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: me</title>
		<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/comment-page-1/#comment-307</link>
		<dc:creator>me</dc:creator>
		<pubDate>Wed, 16 Jun 2010 07:38:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=100#comment-307</guid>
		<description>be sure to replace the ” with regular quotes when copy &amp; paste this function ... otherwise the compiler will get an error ...</description>
		<content:encoded><![CDATA[<p>be sure to replace the ” with regular quotes when copy &amp; paste this function &#8230; otherwise the compiler will get an error &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sugiarto</title>
		<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/comment-page-1/#comment-249</link>
		<dc:creator>sugiarto</dc:creator>
		<pubDate>Mon, 23 Nov 2009 21:56:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=100#comment-249</guid>
		<description>Thanks,
very help me..</description>
		<content:encoded><![CDATA[<p>Thanks,<br />
very help me..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan J</title>
		<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/comment-page-1/#comment-235</link>
		<dc:creator>Dan J</dc:creator>
		<pubDate>Wed, 26 Aug 2009 17:02:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=100#comment-235</guid>
		<description>I think you need to include &quot; in the list of escaped characters.  Don&#039;t forget to escape it in code, e.g. 

CFSTR(”:/?#[]@!$&amp;’()*+,;=\&quot;”)

http://en.wikipedia.org/wiki/Percent-encoding

This was very useful - thanks!</description>
		<content:encoded><![CDATA[<p>I think you need to include &#8221; in the list of escaped characters.  Don&#8217;t forget to escape it in code, e.g. </p>
<p>CFSTR(”:/?#[]@!$&amp;’()*+,;=\&#8221;”)</p>
<p><a href="http://en.wikipedia.org/wiki/Percent-encoding" rel="nofollow">http://en.wikipedia.org/wiki/Percent-encoding</a></p>
<p>This was very useful &#8211; thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samuel</title>
		<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/comment-page-1/#comment-34</link>
		<dc:creator>Samuel</dc:creator>
		<pubDate>Mon, 27 Apr 2009 19:09:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=100#comment-34</guid>
		<description>Thanks, that&#039;s correct! I have edited the post!

+ (NSString *)urlEncodeValue:(NSString *)str
{
	NSString *result = (NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)str, NULL, CFSTR(&quot;:/?#[]@!$&amp;’()*+,;=&quot;), kCFStringEncodingUTF8);
	return [result autorelease];
}</description>
		<content:encoded><![CDATA[<p>Thanks, that&#8217;s correct! I have edited the post!</p>
<p>+ (NSString *)urlEncodeValue:(NSString *)str<br />
{<br />
	NSString *result = (NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)str, NULL, CFSTR(&#8220;:/?#[]@!$&#038;’()*+,;=&#8221;), kCFStringEncodingUTF8);<br />
	return [result autorelease];<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: onitake</title>
		<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/comment-page-1/#comment-33</link>
		<dc:creator>onitake</dc:creator>
		<pubDate>Mon, 27 Apr 2009 15:55:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=100#comment-33</guid>
		<description>unfortunately, this will not correctly escape characters reserved as uri part delimiters or sub-part delimiters.
if you want to do that roll your own converter or use CFURLCreateStringByAddingPercentEscapes instead. as you might already know, corefoundation is toll-free bridged to foundation, so you can just cast between cfstring and nsstring. but don&#039;t forget to release/autorelease.

example:
NSString *encodedString = (NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef) unencodedString, NULL, NULL, kCFStringEncodingUTF8);

if you want to make it rfc 3986-safe, use the following code:
CFStringRef escapeChars = (CFStringRef) @&quot;:/?#[]@!$&amp;&#039;()*+,;=&quot;;NSString *encodedString = (NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef) unencodedString, NULL, escapeChars, kCFStringEncodingUTF8);</description>
		<content:encoded><![CDATA[<p>unfortunately, this will not correctly escape characters reserved as uri part delimiters or sub-part delimiters.<br />
if you want to do that roll your own converter or use CFURLCreateStringByAddingPercentEscapes instead. as you might already know, corefoundation is toll-free bridged to foundation, so you can just cast between cfstring and nsstring. but don&#8217;t forget to release/autorelease.</p>
<p>example:<br />
NSString *encodedString = (NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef) unencodedString, NULL, NULL, kCFStringEncodingUTF8);</p>
<p>if you want to make it rfc 3986-safe, use the following code:<br />
CFStringRef escapeChars = (CFStringRef) @&#8221;:/?#[]@!$&amp;&#8217;()*+,;=&#8221;;NSString *encodedString = (NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef) unencodedString, NULL, escapeChars, kCFStringEncodingUTF8);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Strömberg</title>
		<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/comment-page-1/#comment-7</link>
		<dc:creator>Peter Strömberg</dc:creator>
		<pubDate>Wed, 08 Apr 2009 21:06:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=100#comment-7</guid>
		<description>Ah, an iPhone category. Nice! Could someone explain to me why encoding is such a tricky subject? =)</description>
		<content:encoded><![CDATA[<p>Ah, an iPhone category. Nice! Could someone explain to me why encoding is such a tricky subject? =)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

