Why is PHP Treating Carriage Return / Linefeed Combo as a Single Byte?
<p>I have a php script that truncates a string at 41 bytes. I call strlen on the string to check its size. However, if the string has a "\r\n" combo, this combo is treated as one byte. So in my case instead of 42 bytes, PHP thinks it is 41 bytes.</p>

<p>Also substr truncates it to 42 instead of 41 bytes.</p>

<pre><code>  if (strlen($value) &gt; 41)
  {
   $value = substr($value, 0, 41);
</code></pre>

<p>Another weird condition. I have a large set of data I am passing through this function. Thousands of strings. If I use a simpler test data set then the code works correctly, treating "\r\n" as 2 bytes.</p>

<p>Any ideas?
Thanks.</p>
