note 37694 modified in function.utf8-decode by didou

From: Date: Tue, 25 Nov 2003 10:25:19 +0000
Subject: note 37694 modified in function.utf8-decode by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-60956@lists.php.net to get a copy of this message
There is an error in the 'smart_utf8_decode' function posted by ' goran_johansson' below. It should look like this: 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($new_str); // if it contains ? marks if (strpos($new_str,"?") !== false) { // 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; } --was-- There is an error in the 'smart_utf8_decode' function posted by ' goran_johansson' below. It should look like this: 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($new_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; } http://www.php.net/manual/en/function.utf8-decode.php

« previous php.notes (#60956) next »