<?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>Libre Things &#187; UTF8</title>
	<atom:link href="http://positon.org/tag/utf8/feed" rel="self" type="application/rss+xml" />
	<link>http://positon.org</link>
	<description></description>
	<lastBuildDate>Tue, 23 Feb 2016 20:01:11 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.7.1</generator>
	<item>
		<title>PHP escapeshellarg function, UTF8 and locales</title>
		<link>http://positon.org/php-escapeshellarg-function-utf8-and-locales</link>
		<comments>http://positon.org/php-escapeshellarg-function-utf8-and-locales#comments</comments>
		<pubDate>Tue, 14 Jun 2011 22:09:00 +0000</pubDate>
		<dc:creator><![CDATA[dooblem]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[locales]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[UTF8]]></category>

		<guid isPermaLink="false">http://positon.org:81/?p=111</guid>
		<description><![CDATA[The PHP escapeshellarg function depends on your current locale. I think it&#8217;s bad, but PHP developers made this choice. If like me your default locale is &#8216;C&#8217; you lose all UTF8 characters. They suggest you to call something like setlocale(LC_CTYPE, "en_US.UTF-8"). It doesn&#8217;t work if the en_US.utf8 locale is not installed on your system. Of [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>The PHP <code>escapeshellarg</code> function depends on your current locale. I think it&#8217;s bad, but PHP developers made this choice. If like me your default locale is &#8216;C&#8217; you lose all UTF8 characters.</p>
<p>They suggest you to call something like <code>setlocale(LC_CTYPE, "en_US.UTF-8")</code>. It doesn&#8217;t work if the <code>en_US.utf8</code> locale is not installed on your system. Of course maybe you have the <code>fr_FR.utf8</code>, or <code>de_DE.utf8</code>, but you will have to try all of them until you find one utf8 matching locale. And if there is not, you&#8217;re screwed. It&#8217;s also bad if you want code that runs everywhere.</p>
<p>Simply use that:</p>
<pre>
$escapedArg = &quot;'&quot;.str_replace(&quot;'&quot;, &quot;'\\''&quot;, $arg).&quot;'&quot;;
</pre>
<p>It will do the same as the <code>escapeshellarg</code> function: replace <code>yourstringthat'slong</code> by</p>
<pre>
'yourstringthat'\''slong'
</pre>
<p>as described in the <a href="http://www.php.net/escapeshellarg">escapeshellarg manual</a> (and I also looked into the PHP source code to be sure).</p>
<p>See also:</p>
<ul>
<li><a href="http://www.php.net/escapeshellarg" title="http://www.php.net/escapeshellarg">http://www.php.net/escapeshellarg</a></li>
<li><a href="http://bugs.php.net/bug.php?id=44945" title="http://bugs.php.net/bug.php?id=44945">http://bugs.php.net/bug.php?id=44945</a></li>
<li><a href="http://bugs.php.net/bug.php?id=44564" title="http://bugs.php.net/bug.php?id=44564">http://bugs.php.net/bug.php?id=44564</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://positon.org/php-escapeshellarg-function-utf8-and-locales/feed</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
	</channel>
</rss>
