<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: The magic empty string that is not empty</title>
	<atom:link href="http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/</link>
	<description>Ivo's blog about PHP, the internet and life in general</description>
	<pubDate>Fri, 30 Jul 2010 15:06:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Andries Seutens</title>
		<link>http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/comment-page-1/#comment-122291</link>
		<dc:creator>Andries Seutens</dc:creator>
		<pubDate>Thu, 15 May 2008 12:31:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/#comment-122291</guid>
		<description>Hi Ivo,

As others have indicated, this is the UTF-8 BOM (byte order mark). Here's how you can reproduce the above:

&#60;?php

header('Content-Type: text/html; charset=utf-8');

$string = chr(0xEF) . chr(0xBB) . chr(0xBF);
var_dump($string);</description>
		<content:encoded><![CDATA[<p><!-- google_ad_section_start -->Hi Ivo,</p>
<p>As others have indicated, this is the UTF-8 BOM (byte order mark). Here&#8217;s how you can reproduce the above:</p>
<p>&lt;?php</p>
<p>header(&#8217;Content-Type: text/html; charset=utf-8&#8242;);</p>
<p>$string = chr(0xEF) . chr(0xBB) . chr(0xBF);<br />
var_dump($string);<!-- google_ad_section_end --></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fantata</title>
		<link>http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/comment-page-1/#comment-122061</link>
		<dc:creator>fantata</dc:creator>
		<pubDate>Thu, 15 May 2008 09:00:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/#comment-122061</guid>
		<description>yeah, i've had this a lot as i do a lot of importing from external csv's. It invariably is a BOM. If I'm in BBE Edit, you can switch to UTF8-NO_BOM mode, and it also has a handy 'Zap Gremlins' function, which gets rid of this kind of thing.

It's on my list to work out a way of better dealing with this in the upload.</description>
		<content:encoded><![CDATA[<p><!-- google_ad_section_start -->yeah, i&#8217;ve had this a lot as i do a lot of importing from external csv&#8217;s. It invariably is a BOM. If I&#8217;m in BBE Edit, you can switch to UTF8-NO_BOM mode, and it also has a handy &#8216;Zap Gremlins&#8217; function, which gets rid of this kind of thing.</p>
<p>It&#8217;s on my list to work out a way of better dealing with this in the upload.<!-- google_ad_section_end --></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Priebsch</title>
		<link>http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/comment-page-1/#comment-121961</link>
		<dc:creator>Stefan Priebsch</dc:creator>
		<pubDate>Thu, 15 May 2008 05:30:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/#comment-121961</guid>
		<description>You might want to use check for strlen(...) == 0 instead, this should give you the expected result even when the string contains non-printable characters (and Unicode even has whitespace that has no length, because in some Asian languages they do not leave space between the individual words).

Stefan</description>
		<content:encoded><![CDATA[<p><!-- google_ad_section_start -->You might want to use check for strlen(&#8230;) == 0 instead, this should give you the expected result even when the string contains non-printable characters (and Unicode even has whitespace that has no length, because in some Asian languages they do not leave space between the individual words).</p>
<p>Stefan<!-- google_ad_section_end --></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivo</title>
		<link>http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/comment-page-1/#comment-121631</link>
		<dc:creator>Ivo</dc:creator>
		<pubDate>Wed, 14 May 2008 22:18:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/#comment-121631</guid>
		<description>Thanks for all the input! 

@picco: you're wrong; it does output "Hello "; variable interpolation in PHP when you use double quotes. But that wasn't the point of the message. :)</description>
		<content:encoded><![CDATA[<p><!-- google_ad_section_start -->Thanks for all the input! </p>
<p>@picco: you&#8217;re wrong; it does output &#8220;Hello &#8220;; variable interpolation in PHP when you use double quotes. But that wasn&#8217;t the point of the message. <img src='http://www.jansch.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <!-- google_ad_section_end --></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Dempster</title>
		<link>http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/comment-page-1/#comment-121391</link>
		<dc:creator>James Dempster</dc:creator>
		<pubDate>Wed, 14 May 2008 19:58:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/#comment-121391</guid>
		<description>dam it that was supposed to say trim() wouldn't remove it.</description>
		<content:encoded><![CDATA[<p><!-- google_ad_section_start -->dam it that was supposed to say trim() wouldn&#8217;t remove it.<!-- google_ad_section_end --></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Dempster</title>
		<link>http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/comment-page-1/#comment-121381</link>
		<dc:creator>James Dempster</dc:creator>
		<pubDate>Wed, 14 May 2008 19:57:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/#comment-121381</guid>
		<description>I had a similar problem once. trim() would remove it either. As Derick Rethans says it was a non breaking space. I found out that a client had copied and pasted a table from a website into excel and then saved it as CSV file. The table contained &#160; which excel translated to non breaking space.</description>
		<content:encoded><![CDATA[<p><!-- google_ad_section_start -->I had a similar problem once. trim() would remove it either. As Derick Rethans says it was a non breaking space. I found out that a client had copied and pasted a table from a website into excel and then saved it as CSV file. The table contained &nbsp; which excel translated to non breaking space.<!-- google_ad_section_end --></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edward Z. Yang</title>
		<link>http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/comment-page-1/#comment-121261</link>
		<dc:creator>Edward Z. Yang</dc:creator>
		<pubDate>Wed, 14 May 2008 17:43:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/#comment-121261</guid>
		<description>If you wanted to find out conclusively, just urlencode() the string and check out what its binary representation is.

What you really should be doing is checking the character encoding of incoming strings with the u PCRE flag or iconv.</description>
		<content:encoded><![CDATA[<p><!-- google_ad_section_start -->If you wanted to find out conclusively, just urlencode() the string and check out what its binary representation is.</p>
<p>What you really should be doing is checking the character encoding of incoming strings with the u PCRE flag or iconv.<!-- google_ad_section_end --></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Picco</title>
		<link>http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/comment-page-1/#comment-121151</link>
		<dc:creator>Picco</dc:creator>
		<pubDate>Wed, 14 May 2008 15:35:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/#comment-121151</guid>
		<description>hi,
if ($str!='')
{
   echo "Hello $str";
}
  returns
Hello $str
not Hello (what in the var is)

if ($str!='')
{
   echo "Hello ".$str;
}
is what u mean^^ 
me sorry if anyone have sayd this allready</description>
		<content:encoded><![CDATA[<p><!-- google_ad_section_start -->hi,<br />
if ($str!=&#8221;)<br />
{<br />
   echo &#8220;Hello $str&#8221;;<br />
}<br />
  returns<br />
Hello $str<br />
not Hello (what in the var is)</p>
<p>if ($str!=&#8221;)<br />
{<br />
   echo &#8220;Hello &#8220;.$str;<br />
}<br />
is what u mean^^<br />
me sorry if anyone have sayd this allready<!-- google_ad_section_end --></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lorenzo Alberton</title>
		<link>http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/comment-page-1/#comment-121141</link>
		<dc:creator>Lorenzo Alberton</dc:creator>
		<pubDate>Wed, 14 May 2008 15:34:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/#comment-121141</guid>
		<description>As others have already suggested, it's most certainly a BOM.</description>
		<content:encoded><![CDATA[<p><!-- google_ad_section_start -->As others have already suggested, it&#8217;s most certainly a BOM.<!-- google_ad_section_end --></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sepa</title>
		<link>http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/comment-page-1/#comment-121121</link>
		<dc:creator>Sepa</dc:creator>
		<pubDate>Wed, 14 May 2008 14:51:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.jansch.nl/2008/05/14/the-magic-empty-string-that-is-not-empty/#comment-121121</guid>
		<description>I've recently ran into similar problem. I was importing CSV files, when noticed that some of the strings are "strange" in a similar manner like yours. I've outputed some of them and found  they're set of one or two strange characters, but while viewing the CSV in OpenOffice Calc or MS Excel the're represented as spaces.

I was not able to solve this problem in my code, so I had to catch these baddies :) using OOCalc. Thankfully, all of these characters were at the beginning of a text in a cell, so when opened with a CSV viewer it can be clearly seen that cells with content like this: " Vilnius" or "  Kaunas" needs to be checked twice.</description>
		<content:encoded><![CDATA[<p><!-- google_ad_section_start -->I&#8217;ve recently ran into similar problem. I was importing CSV files, when noticed that some of the strings are &#8220;strange&#8221; in a similar manner like yours. I&#8217;ve outputed some of them and found  they&#8217;re set of one or two strange characters, but while viewing the CSV in OpenOffice Calc or MS Excel the&#8217;re represented as spaces.</p>
<p>I was not able to solve this problem in my code, so I had to catch these baddies <img src='http://www.jansch.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> using OOCalc. Thankfully, all of these characters were at the beginning of a text in a cell, so when opened with a CSV viewer it can be clearly seen that cells with content like this: &#8221; Vilnius&#8221; or &#8221;  Kaunas&#8221; needs to be checked twice.<!-- google_ad_section_end --></p>
]]></content:encoded>
	</item>
</channel>
</rss>
