<?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>Dolbex &#187; CakePHP</title>
	<atom:link href="http://www.dolbex.com/category/cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dolbex.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 14 Oct 2009 14:21:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CakePHP and Encoding Problems &#8211; Solves International and Word Special Chars</title>
		<link>http://www.dolbex.com/cakephp-and-encoding-problems-solves-international-and-word-special-chars/</link>
		<comments>http://www.dolbex.com/cakephp-and-encoding-problems-solves-international-and-word-special-chars/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 11:05:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[character]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[microsoft word]]></category>
		<category><![CDATA[special chars]]></category>

		<guid isPermaLink="false">http://www.dolbex.com/?p=63</guid>
		<description><![CDATA[So, embarrassingly I have been putting up with this for years and just never could quite put a finger on how to handle it.  The situation is this: You have some sort of content management system (CMS) setup for your client that you have made homebrew (or not maybe).  You&#8217;ve painstakingly put time into security, [...]]]></description>
			<content:encoded><![CDATA[<p>So, embarrassingly I have been putting up with this for years and just never could quite put a finger on how to handle it.  The situation is this: You have some sort of content management system (CMS) setup for your client that you have made homebrew (<a href="http://www.mattfarina.com/2007/05/24/drupal-module-highlight-handy-filters-churches-and-businesses" target="_blank">or not maybe</a>).  You&#8217;ve painstakingly put time into security, format, ease of use, etc and you hand them the rains. Two hours later you get a call that they have some &#8216;weird code&#8217; on their about page. You look and you realize they have copied and pasted some special chars from Word.  What to do?</p>
<p>Maybe this is the jerk way of handling it but I always had users copy and paste from word into a flat text file, then copy and paste into the form.  Or, I would use TinyMCE in the CMS and have their Cleaner plugin handle it. Most of the time that seems to work but not always. Today, I hit the wall on this problem with CakePHP and had to figure it out. Essentially, it all comes down to page and database encoding.</p>
<p>The short explanation:<span style="color: #ff0000;"> <strong>Set everything to UTF-8 at the beginning of your project.</strong></span> The long explanation (which is just a rehash of this awesome post at <a href="http://missingfeatures.com/2008/10/23/using-utf8-in-your-cakephp-app/" target="_blank">missingfeatures.com</a>):</p>
<ol>
<li>Set your mySQL database up with UTF-8 encoding.  This includes:
<ol>
<li>The database itself</li>
<li>The tables</li>
<li>Every field <em>(watch out for this one in phpmyadmin because if you have already created your table you&#8217;ll need to specifically change the collation for all text, varchar, and char fields)</em></li>
</ol>
</li>
<li>In your layouts:
<ol>
<li>Put this at the top:<span style="color: #ff0000;"><strong>&lt;?php header(&#8217;Content-type: text/html; charset=UTF-8&#8242;); ?&gt;</strong></span><strong><em><br />
</em></strong></li>
<li>Put this in the head: <span style="color: #ff0000;"><strong>&lt;?php echo $html-&gt;charset(&#8217;utf-8&#8242;); ?&gt;</strong></span></li>
</ol>
</li>
<li>In your database configuration file (app/config/database.php):
<ol>
<li>Add this to your default database array:<strong> <span style="color: #ff0000;">&#8216;encoding&#8217; =&gt; &#8216;utf8&#8242;</span></strong></li>
</ol>
</li>
</ol>
<p>This puts everything on the same encoding plane and allows for characters like: ü ß ☠  ☮  ☯  ♠  Ω ♤ ♣ ♧  ♥ ♡  ♦ ♢ ♔   ♕   ♚  ♛  ⚜  ★  ☆ ✮  ✯  ☄  ☾ ☽ ☼  ☀  ☁  ☂  ☃ ☻ ☺ ☹   ۞ ۩</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dolbex.com/cakephp-and-encoding-problems-solves-international-and-word-special-chars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
