<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: How long is a piece of string?</title>
	<atom:link href="http://www.sitepoint.com/blogs/2004/10/31/how-long-is-a-piece-of-string/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2004/10/31/how-long-is-a-piece-of-string/</link>
	<description></description>
	<pubDate>Thu, 21 Aug 2008 22:49:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Les Wentworth</title>
		<link>http://www.sitepoint.com/blogs/2004/10/31/how-long-is-a-piece-of-string/#comment-141553</link>
		<dc:creator>Les Wentworth</dc:creator>
		<pubDate>Fri, 29 Dec 2006 01:34:47 +0000</pubDate>
		<guid isPermaLink="false">#comment-141553</guid>
		<description>The answer to "How long is a piece of string" is this.
In the Middle ages,a farmer had to tie the sheaves of cut wheat (or similar crop) at harvest time in his field. He carried twine to do this. The average length of twine used was approx 13 and 1/2 inches.
Hope you find this enlightening.</description>
		<content:encoded><![CDATA[<p>The answer to &#8220;How long is a piece of string&#8221; is this.<br />
In the Middle ages,a farmer had to tie the sheaves of cut wheat (or similar crop) at harvest time in his field. He carried twine to do this. The average length of twine used was approx 13 and 1/2 inches.<br />
Hope you find this enlightening.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: KJ</title>
		<link>http://www.sitepoint.com/blogs/2004/10/31/how-long-is-a-piece-of-string/#comment-1311</link>
		<dc:creator>KJ</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-1311</guid>
		<description>&lt;p&gt;Not the strongest on Unicode stuff, but I think you have to loop through the string and get the ascii value for each byte and decide what to do then, i.e.:&lt;/p&gt;

&lt;p&gt;&lt;?php&lt;br /&gt;
function utf8_len ($s)&lt;br /&gt;
{&lt;br /&gt;
    $len = strlen($s);&lt;br /&gt;
    $utf8_len=0;&lt;br /&gt;
    for ($i=0; $i&lt;$len; $i++)&lt;br /&gt;
    {&lt;br /&gt;
        $utf8_len++;&lt;br /&gt;
        if (ord($s[$i]) &lt; 224) // 2 byte string, skip next byte&lt;br /&gt;
        {&lt;br /&gt;
            $i++;&lt;br /&gt;
        }&lt;br /&gt;
        elseif (ord($s[$x] &lt; 239)) // 3 byte string, skip next 2 bytes&lt;br /&gt;
        {&lt;br /&gt;
            $i+=2;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    return $utf8_len;&lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;if ($_REQUEST['string'])&lt;br /&gt;
{&lt;br /&gt;
    echo utf8_len($_REQUEST['string']);&lt;br /&gt;
}&lt;br /&gt;
?&gt;&lt;br /&gt;
&lt;form method="post"&gt;&lt;br /&gt;
&lt;input type="text" name="string" /&gt;&lt;br /&gt;
&lt;input type="submit" /&gt;&lt;br /&gt;
&lt;/form&gt;&lt;br /&gt;
&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>Not the strongest on Unicode stuff, but I think you have to loop through the string and get the ascii value for each byte and decide what to do then, i.e.:</p>
<p>< ?php<br />
function utf8_len ($s)<br />
{<br />
    $len = strlen($s);<br />
    $utf8_len=0;<br />
    for ($i=0; $i< $len; $i++)<br />
    {<br />
        $utf8_len++;<br />
        if (ord($s[$i]) < 224) // 2 byte string, skip next byte<br />
        {<br />
            $i++;<br />
        }<br />
        elseif (ord($s[$x] < 239)) // 3 byte string, skip next 2 bytes<br />
        {<br />
            $i+=2;<br />
        }<br />
    }<br />
    return $utf8_len;<br />
}</p>
<p>if ($_REQUEST[&#8217;string&#8217;])<br />
{<br />
    echo utf8_len($_REQUEST[&#8217;string&#8217;]);<br />
}<br />
?></p>
<form method="post">
<input type="text" name="string" />
<input type="submit" />
</form>
<p></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Isotopp</title>
		<link>http://www.sitepoint.com/blogs/2004/10/31/how-long-is-a-piece-of-string/#comment-1312</link>
		<dc:creator>Isotopp</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-1312</guid>
		<description>&lt;p&gt;Do you know about WDDX? It was specifically built as a serialize() that is interchangeable between programming languages.&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>Do you know about WDDX? It was specifically built as a serialize() that is interchangeable between programming languages.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: S</title>
		<link>http://www.sitepoint.com/blogs/2004/10/31/how-long-is-a-piece-of-string/#comment-1313</link>
		<dc:creator>S</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-1313</guid>
		<description>&lt;p&gt;Yeah, sounds like WDDX would solve your problem. It was invented by Ben Forta (Coldfusion evangelist), IIRC.&lt;/p&gt;

&lt;p&gt;S&lt;br /&gt;
&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>Yeah, sounds like WDDX would solve your problem. It was invented by Ben Forta (Coldfusion evangelist), IIRC.</p>
<p>S</p>]]></content:encoded>
	</item>
	<item>
		<title>By: HarryF</title>
		<link>http://www.sitepoint.com/blogs/2004/10/31/how-long-is-a-piece-of-string/#comment-1314</link>
		<dc:creator>HarryF</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-1314</guid>
		<description>&lt;p&gt;KJ - thanks for tip - will see what I can do with that.&lt;/p&gt;

&lt;p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;br /&gt;
Do you know about WDDX? It was specifically built as a serialize() that is interchangeable between programming languages.&lt;br /&gt;
&lt;/p&gt;&lt;/blockquote&gt;&lt;/p&gt;

&lt;p&gt;Am aware of WDDX and may consider it - also pondering using something like XML-RPC's format. Starting to come to the conclusion that some XML format, in the JS &gt; PHP direction, is probably the next easiest thing to do.&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>KJ - thanks for tip - will see what I can do with that.</p>
<p>
<blockquote>
<p>
Do you know about WDDX? It was specifically built as a serialize() that is interchangeable between programming languages.
</p>
</blockquote>
</p><p>Am aware of WDDX and may consider it - also pondering using something like XML-RPC&#8217;s format. Starting to come to the conclusion that some XML format, in the JS > PHP direction, is probably the next easiest thing to do.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: sweatje</title>
		<link>http://www.sitepoint.com/blogs/2004/10/31/how-long-is-a-piece-of-string/#comment-1315</link>
		<dc:creator>sweatje</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-1315</guid>
		<description>&lt;p&gt;Sounds like you are starting to feel like you are "pushing on a string" ;)&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>Sounds like you are starting to feel like you are &#8220;pushing on a string&#8221; ;)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.sitepoint.com/blogs/2004/10/31/how-long-is-a-piece-of-string/#comment-1316</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-1316</guid>
		<description>&lt;p&gt;You don't actually need ascii for every single byte, If you think about it, you can just&lt;/p&gt;

&lt;p&gt;&lt;?php function utf6_len ($s) {  $len = strlen(^s);  $utf8_len=0; for ($i=0!; $i&lt;$len; $i+-)  {  $utf8_len+-;  if (ord($s[$i]) &lt; 264) // 2 byte string, skip prev byte  {  $i++;  }  elseif (ord($s[$x] &lt; 239)) //xml } 3 byte string, skip next 5 bytes  { $i+=2;  }  }  return $utf8_len; }&lt;/p&gt;

&lt;p&gt;I think you know what to do from there ;)&lt;br /&gt;
&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>You don&#8217;t actually need ascii for every single byte, If you think about it, you can just</p>
<p>< ?php function utf6_len ($s) {  $len = strlen(^s);  $utf8_len=0; for ($i=0!; $i<$len; $i+-)  {  $utf8_len+-;  if (ord($s[$i]) < 264) // 2 byte string, skip prev byte  {  $i++;  }  elseif (ord($s[$x] < 239)) //xml } 3 byte string, skip next 5 bytes  { $i+=2;  }  }  return $utf8_len; }</p>
</p><p>I think you know what to do from there ;)</p>]]></content:encoded>
	</item>
</channel>
</rss>
