<?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>LogikDevelopment &#187; UTF-8</title>
	<atom:link href="http://www.logikdev.com/tag/utf-8/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.logikdev.com</link>
	<description>&#34;Il n&#039;y a pas de problème, il n&#039;y a que des solutions. L&#039;esprit de l&#039;homme invente ensuite le problème.&#34; André Gide</description>
	<lastBuildDate>Tue, 20 Dec 2011 12:25:13 +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>Locale settings for your cron job</title>
		<link>http://www.logikdev.com/2010/02/02/locale-settings-for-your-cron-job/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=locale-settings-for-your-cron-job</link>
		<comments>http://www.logikdev.com/2010/02/02/locale-settings-for-your-cron-job/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 22:55:35 +0000</pubDate>
		<dc:creator>smoreau</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[locale]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[UTF-8]]></category>

		<guid isPermaLink="false">http://www.logikdev.com/?p=291</guid>
		<description><![CDATA[Do you get special characters problem when executing your bash script from a cron job? And does the same script work fine when it is directly executed from the command line? If yes, continue reading this article! The reason of this characters problem is probably because of your locale settings. Indeed, If you try to [...]]]></description>
			<content:encoded><![CDATA[<p>Do you get special characters problem when executing your bash script from a cron job?<br />
And does the same script work fine when it is directly executed from the command line?<br />
If yes, continue reading this article! <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The reason of this characters problem is probably because of your locale settings.<br />
Indeed, If you try to run the command <code>locale</code> from the command line and from a cron job, you may get different results such as:</p>
<table style="width: 100%; border:0px;">
<tbody>
<tr>
<td style="width:50%; border:0px;">From the command line</td>
<td style="width:50%; border:0px;">From a cron job</td>
</tr>
<tr>
<td style="border:0px;">
<pre class="brush: bash; light: true; title: ; notranslate">
LANG=en_US.UTF-8
LC_CTYPE=&quot;en_US.UTF-8&quot;
LC_NUMERIC=&quot;en_US.UTF-8&quot;
LC_TIME=&quot;en_US.UTF-8&quot;
LC_COLLATE=&quot;en_US.UTF-8&quot;
LC_MONETARY=&quot;en_US.UTF-8&quot;
LC_MESSAGES=&quot;en_US.UTF-8&quot;
LC_PAPER=&quot;en_US.UTF-8&quot;
LC_NAME=&quot;en_US.UTF-8&quot;
LC_ADDRESS=&quot;en_US.UTF-8&quot;
LC_TELEPHONE=&quot;en_US.UTF-8&quot;
LC_MEASUREMENT=&quot;en_US.UTF-8&quot;
LC_IDENTIFICATION=&quot;en_US.UTF-8&quot;
LC_ALL=
</pre>
</td>
<td style="border:0px;">
<pre class="brush: bash; light: true; title: ; notranslate">
LANG=
LC_CTYPE=&quot;POSIX&quot;
LC_NUMERIC=&quot;POSIX&quot;
LC_TIME=&quot;POSIX&quot;
LC_COLLATE=&quot;POSIX&quot;
LC_MONETARY=&quot;POSIX&quot;
LC_MESSAGES=&quot;POSIX&quot;
LC_PAPER=&quot;POSIX&quot;
LC_NAME=&quot;POSIX&quot;
LC_ADDRESS=&quot;POSIX&quot;
LC_TELEPHONE=&quot;POSIX&quot;
LC_MEASUREMENT=&quot;POSIX&quot;
LC_IDENTIFICATION=&quot;POSIX&quot;
LC_ALL=
</pre>
</td>
</tr>
</tbody>
</table>
<p>As you can see, the cron job is not using UTF-8. That must be the problem! <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><br/>So the question now is how to change the locale settings for the cron job?<br />
Some people say that you need to add the following environment variables to the crontab entry:</p>
<pre class="brush: bash; light: true; title: ; notranslate">
SHELL=/bin/bash
LANG=en_US.UTF-8
LANGUAGE=en
LC_CTYPE=en_US.UTF-8
</pre>
<p>But this actually didn&#8217;t work for me. <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><br/>What you can do instead is create (if not already present) the file <code>/etc/environment</code> and add the following line:</p>
<pre class="brush: bash; light: true; title: ; notranslate">
LANG=en_US.UTF-8
</pre>
<p>The cron process will read this file when it starts, so you need to restart it in order to apply the change:</p>
<pre class="brush: bash; light: true; title: ; notranslate">
service cron restart
</pre>
<p><br/>Hope this will fix your characters problem. <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.logikdev.com/2010/02/02/locale-settings-for-your-cron-job/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

