<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Thomas Gabrielsens weblog &#187; PHP</title>
	<atom:link href="http://arton.no/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://arton.no</link>
	<description>Just another weblog</description>
	<lastBuildDate>Sun, 05 Feb 2012 11:29:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Adobe Air, SQLite,  and apostrophes</title>
		<link>http://arton.no/2010/03/16/adobe-air-sqlite-and-apostrophes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=adobe-air-sqlite-and-apostrophes</link>
		<comments>http://arton.no/2010/03/16/adobe-air-sqlite-and-apostrophes/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 13:04:30 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[escape()]]></category>
		<category><![CDATA[rawurldecode()]]></category>
		<category><![CDATA[rawurlencode()]]></category>
		<category><![CDATA[unescape()]]></category>

		<guid isPermaLink="false">http://arton.no/blog/?p=325</guid>
		<description><![CDATA[I&#8217;m currently developing an Air application and I run into a problem inserting file names with apostrophe (because apostrophe are used as string delimiter). There are several ways to handle this problem. You can add two apostrophes, and Jake Churchill has made a function for this. While working with back-end I&#8217;ve used PHP&#8217;s utf8_encode edit: [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently developing an Air application and I run into a problem   inserting file names with apostrophe (because apostrophe are used as   string delimiter). There are several ways to handle this problem. You   can add two apostrophes, and <a href="http://www.reynacho.com/2008/08/custom-object-parsing-function/">Jake Churchill has made a function for   this</a>.</p>
<p>While working with back-end I&#8217;ve used PHP&#8217;s <span style="text-decoration: line-through;"><a href="http://www.php.net/manual/en/function.utf8-encode.php">utf8_encode</a></span> <span style="color: #800000;">edit: I meant <a href="http://php.net/manual/en/function.urlencode.php">rawurlencode()</a> </span>quite a lot, and AS3 has several similar functions, but there is only one that encodes apostrophes, and it&#8217;s called <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/package.html#escape%28%29">escape()</a>. So what you can do is escape() the strings to be inserted into SQLite, and use <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/package.html#unescape%28%29">unescape()</a> after receiving the string back from the database.</p>
<p>Here is an example with escape() and unescape() used in AS3:</p>
<pre class="brush:as3">var testString:String = "This is a test ' with ' several apostrophes'";
trace( testString ); // This is a test ' with ' several apostrophes'
testString = escape( testString );
trace( testString ); //This%20is%20a%20test%20%27%20with%20%27%20several%20apostrophes%27
testString = unescape( testString );
trace( testString ); //This is a test ' with ' several apostrophes'</pre>
<p>Here is an example with rawurlencode and rawurldecode() used in PHP:</p>
<pre class="brush:php">$testString = "This is a test ' with ' several apostrophes'";
echo $testString . "
"; // This is a test ' with ' several apostrophes'
$testString = rawurlencode( $testString );
echo $testString . "
"; // This%20is%20a%20test%20%27%20with%20%27%20several%20apostrophes%27
$testString = rawurldecode( $testString );
echo $testString . "
"; // This is a test ' with ' several apostrophes'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://arton.no/2010/03/16/adobe-air-sqlite-and-apostrophes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

