Z.N.S.: UTF8 oder ISO-8859-1, das ist hier die frag....

Beitrag lesen

abend,

(http://www.php.net/manual/de/function.utf8-decode.php)
---zitat---
I needed a way to found out if the actual string contains
Unicodechars or not before trying utf8_decode on the string,
because if it is not you will get the ugly ?-marks.
To solve this, I made this function which works for me.

function smart_utf8_decode($in_str)
{
// Replace ? with a unique string
   $new_str = str_replace("?", "q0u0e0s0t0i0o0n", $in_str);
// Try the utf8_decode
   $new_str=utf8_decode($in_str);
// if it contains ? marks
   if (strpos($new_str,"?")>0)
   {
      // Something went wrong, set new_str to the original string.
      $new_str=$in_str;
   }
   else
   {
      // If not then all is well, put the ?-marks back where is belongs
      $new_str = str_replace("q0u0e0s0t0i0o0n", "?", $new_str);
   }
return $new_str;
}
---zitat---

mfg,
(tanz das)
Z.N.S.

--
<img src="http://www.dmp-web.de/comunicout/neubauten.gif" border="0" alt="">