<?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"
	>

<channel>
	<title>Eat my monkeydust &#187; Web</title>
	<atom:link href="http://eatmymonkeydust.com/category/Web/feed" rel="self" type="application/rss+xml" />
	<link>http://eatmymonkeydust.com</link>
	<description>Life, PHP and Symfony - straight from the monkey's mouth</description>
	<pubDate>Mon, 04 Aug 2008 08:57:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>UTF-8 and strlen()</title>
		<link>http://eatmymonkeydust.com/2008/04/utf-8-and-strlen/</link>
		<comments>http://eatmymonkeydust.com/2008/04/utf-8-and-strlen/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 10:14:27 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Symfony]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[Encoding]]></category>

		<category><![CDATA[multibyte]]></category>

		<category><![CDATA[strlen]]></category>

		<category><![CDATA[UTF-8]]></category>

		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=9</guid>
		<description><![CDATA[Trying to find out the length of a string and wondering why the values are often wrong?
UTF-8 characters can be multi-byte, and strlen() returns the length of the string in bytes, which means the string ååå would actually have a &#8220;length&#8221; of 6.
One solution is to use the multibyte function &#8220;mb_strlen&#8221; instead, you will need [...]]]></description>
			<content:encoded><![CDATA[<p>Trying to find out the length of a string and wondering why the values are often wrong?</p>
<p>UTF-8 characters can be multi-byte, and strlen() returns the length of the string in bytes, which means the string ååå would actually have a &#8220;length&#8221; of 6.</p>
<p>One solution is to use the multibyte function &#8220;mb_strlen&#8221; instead, you will need to have PHP compiled with this - but it seems to be a default in later versions.</p>
<p>E.g.</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #ff0000">$value</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;ÅØÆbob&quot;</span><span style="color: #66cc66;">;</span>
<span style="color: #000066;">echo</span> <span style="color: #000066;">strlen</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$value</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #808080; font-style: italic;">// 9</span>
&nbsp;
<span style="color: #000066;">echo</span> <span style="color: #000066;">mb_strlen</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$value</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'UTF-8'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #808080; font-style: italic;">// 6</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://eatmymonkeydust.com/2008/04/utf-8-and-strlen/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
