note 64919 deleted from function.utf8-encode by bjori

From: Date: Sun, 23 Apr 2006 00:24:01 +0000
Subject: note 64919 deleted from function.utf8-encode by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-109102@lists.php.net to get a copy of this message
Note Submitter: info at bibliograph dot org Reason: useless ---- These two functions have worked very well for me: <?php function utf8_safe_decode($input) { if ( ! is_string ( $input ) ) return $input; $conv = utf8_decode($input); return ( substr_count($conv, '?') > substr_count($input, '?') ) ? $input : $conv ; } function utf8_safe_encode($input) { if ( ! is_string ($input ) ) return $input; $conv = utf8_decode($input); // if input can be decoded without error, it is already utf-8 return ( substr_count($conv, '?') == substr_count($input, '?') ) ? $input : utf8_encode($input) ; } ?>

« previous php.notes (#109102) next »