<?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>Khelll&#039;s Blog &#187; arabic</title>
	<atom:link href="http://khelll.com/blog/tag/arabic/feed/" rel="self" type="application/rss+xml" />
	<link>http://khelll.com/blog</link>
	<description>Cool Web Development...</description>
	<lastBuildDate>Thu, 13 Oct 2011 03:48:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Changing database encoding from latin1 to UTF8</title>
		<link>http://khelll.com/blog/mysql/changing-database-encoding-from-latin-to-utf8/</link>
		<comments>http://khelll.com/blog/mysql/changing-database-encoding-from-latin-to-utf8/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 20:59:31 +0000</pubDate>
		<dc:creator>khelll</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[arabic]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://www.khelll.com/blog/?p=46</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://khelll.com/blog/mysql/changing-database-encoding-from-latin-to-utf8/' addthis:title='Changing database encoding from latin1 to UTF8 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Now a days, UTF-8 is the most used data encoding format, and the fact that your database is not using UTF8 encoding is really annoying, specially additionally when it comes to integrating different systems, that has no one unified encoding &#8230; <a href="http://khelll.com/blog/mysql/changing-database-encoding-from-latin-to-utf8/">Continue reading <span class="meta-nav">&#8594;</span></a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://khelll.com/blog/mysql/changing-database-encoding-from-latin-to-utf8/' addthis:title='Changing database encoding from latin1 to UTF8' ><a class="addthis_button_twitter"></a><a class="addthis_button_facebook"></a><a class="addthis_button_email"></a><a class="addthis_button_print"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://khelll.com/blog/mysql/changing-database-encoding-from-latin-to-utf8/' addthis:title='Changing database encoding from latin1 to UTF8 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Now a days, <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> is the most used data encoding format, and the fact that your database is not using UTF8 encoding is really annoying, specially additionally when it comes to integrating different systems, that has no one unified encoding format.<br />
So if you think it&#8217;s time to change your data encoding to utf8 format, then here what this post is all about.<br />
I&#8217;ll list here the steps to do so, i just have to clarify that the main data encoding here is windows-1256 (which is the main Arabic encoding used in web applications), but it&#8217;s saved in latin1 encoding in the database (mydata ->windows-1256 -> latin1) ,also note that i&#8217;m  using Mysql database.<br />
Here are the steps:</p>
<ol>
<li>Export (only) the schema of the db,without &#8220;set Names&#8221; phrase in the outputted sql file, this will bring you back the data in the original encoding (windows-1256)

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysqldump <span style="color: #660033;">--default-character-set</span>=latin1 <span style="color: #660033;">--skip-set-charset</span> <span style="color: #660033;">-d</span> <span style="color: #660033;">-uusername</span> <span style="color: #660033;">-ppassword</span> db_name <span style="color: #000000; font-weight: bold;">&gt;</span> db_name_schema.sql</pre></div></div>

</li>
<li>Export the data of the db without &#8220;set Names&#8221; phrase in the outputted sql file, this will bring you back the data in the original encoding (windows-1256):

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysqldump <span style="color: #660033;">--default-character-set</span>=latin1 <span style="color: #660033;">--skip-set-charset</span> <span style="color: #660033;">-t</span> <span style="color: #660033;">-uusername</span> <span style="color: #660033;">-ppassword</span>  db_name <span style="color: #000000; font-weight: bold;">&gt;</span> db_name_data.sql</pre></div></div>

</li>
<li>Change the encoding of both files from arabic to utf8 -check the notes if you r using windows

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iconv <span style="color: #660033;">-f</span> windows-<span style="color: #000000;">1256</span> <span style="color: #660033;">-t</span> utf8 db_name_schema.sql <span style="color: #000000; font-weight: bold;">&gt;</span> db_name_schema_utf8.sql
iconv <span style="color: #660033;">-f</span> windows-<span style="color: #000000;">1256</span> <span style="color: #660033;">-t</span> utf8 db_name_data.sql <span style="color: #000000; font-weight: bold;">&gt;</span> db_name_data_utf8.sql</pre></div></div>

</li>
<li> Open the file &#8216;db_name_schema.sql&#8217; with any editor and replace each &#8220;DEFAULT CHARSET=latin1&#8243; phrase with &#8220;DEFAULT CHARSET=utf8&#8243; one
</li>
<li>Make a new db ,encoded in utf8:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> mysql <span style="color: #660033;">-uusername</span> <span style="color: #660033;">-ppassword</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'CREATE DATABASE new_db DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci'</span></pre></div></div>

</li>
<li>Import the schema and data in utf8 encoding:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">--default-character-set</span>=utf8 <span style="color: #660033;">-uusername</span> <span style="color: #660033;">-ppassword</span> new_db <span style="color: #000000; font-weight: bold;">&lt;</span> db_name_schema_utf8.sql
mysql <span style="color: #660033;">--default-character-set</span>=utf8  <span style="color: #660033;">-uusername</span> <span style="color: #660033;">-ppassword</span> new_db <span style="color: #000000; font-weight: bold;">&lt;</span> db_name_data_utf8.sql</pre></div></div>

</li>
</ol>
<p><strong> notes</strong></p>
<ul>
<li class="level1">
<div class="li">If you are wondering why to separate schema from data upon exporting , then the answer is that the operation of replacing &#8220;DEFAULT CHARSET=latin1&#8243; phrase with &#8220;DEFAULT CHARSET=utf8&#8243; one , is taking place only on schema files, so it&#8217;s recommended to separate them so that you dont stuck when loading the big data files.</div>
</li>
<li class="level1">
<div class="li">If you are a windows user and can&#8217;t use iconv , then u can use any editor to do the job for u, try scite or note++ or even dreamweaver</div>
</li>
</ul>
<p>enjoy!!!</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://khelll.com/blog/mysql/changing-database-encoding-from-latin-to-utf8/' addthis:title='Changing database encoding from latin1 to UTF8' ><a class="addthis_button_twitter"></a><a class="addthis_button_facebook"></a><a class="addthis_button_email"></a><a class="addthis_button_print"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://khelll.com/blog/mysql/changing-database-encoding-from-latin-to-utf8/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Grails and Arabic localization</title>
		<link>http://khelll.com/blog/grails/grails-and-arabic-localization/</link>
		<comments>http://khelll.com/blog/grails/grails-and-arabic-localization/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 16:08:29 +0000</pubDate>
		<dc:creator>khelll</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[arabic]]></category>
		<category><![CDATA[localization]]></category>

		<guid isPermaLink="false">http://www.khelll.com/blog/?p=35</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://khelll.com/blog/grails/grails-and-arabic-localization/' addthis:title='Grails and Arabic localization '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>A little problem that i faced with grails , was setting the locale dynamically, i followed this nice article , and here is how i could manage it : I made a new file called messages_ar.properties that contains the arabic &#8230; <a href="http://khelll.com/blog/grails/grails-and-arabic-localization/">Continue reading <span class="meta-nav">&#8594;</span></a><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://khelll.com/blog/grails/grails-and-arabic-localization/' addthis:title='Grails and Arabic localization' ><a class="addthis_button_twitter"></a><a class="addthis_button_facebook"></a><a class="addthis_button_email"></a><a class="addthis_button_print"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://khelll.com/blog/grails/grails-and-arabic-localization/' addthis:title='Grails and Arabic localization '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>A little problem that i faced with grails , was setting the locale dynamically, i followed this <a href="http://www.grassr.com/wordpress/?p=12">nice article</a> , and here is how i could manage it :</p>
<ol>
<li>I made a new file called messages_ar.properties that contains the arabic localization under the i18n folder.</li>
<li>I made a simple beforeinterceptor:

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> beforeInterceptor <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">def</span> key <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;org.springframework.web.servlet.DispatcherServlet.LOCALE_RESOLVER&quot;</span>
        <span style="color: #000000; font-weight: bold;">def</span> localeResolver <span style="color: #66cc66;">=</span> request.<span style="color: #006600;">getAttribute</span><span style="color: #66cc66;">&#40;</span>key<span style="color: #66cc66;">&#41;</span>
        localeResolver.<span style="color: #006600;">setLocale</span><span style="color: #66cc66;">&#40;</span>request, response, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">Locale</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ar&quot;</span>,<span style="color: #ff0000;">&quot;JO&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span></pre></div></div>

</li>
</ol>
<p>Of course you can use <a href="http://grails.org/Filters">grails/Filters</a> to save yourself repeating the same code in every controller.</p>
<p>However what i want to mention is the locale object, which in case of Arabic localization, was seeking  the country argument ( &#8220;JO&#8221; in our case) :</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">Locale</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ar&quot;</span>,<span style="color: #ff0000;">&quot;JO&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>While for other localizations like German one it doesn&#8217;t seek this second argument, so this snippet of code will work for them <img src='http://khelll.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">Locale</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;de&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Also you can change this country argument value to match this rule :</p>
<blockquote><p>
The country argument is a valid ISO Country Code. These codes are the upper-case, two-letter codes as defined by ISO-3166. You can find a full list of these codes at a number of sites, such as:</p>
<p>http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</p></blockquote>
<p>I hope that was helpful <img src='http://khelll.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  , enjoy!</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://khelll.com/blog/grails/grails-and-arabic-localization/' addthis:title='Grails and Arabic localization' ><a class="addthis_button_twitter"></a><a class="addthis_button_facebook"></a><a class="addthis_button_email"></a><a class="addthis_button_print"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://khelll.com/blog/grails/grails-and-arabic-localization/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

