note 59710 added to function.utf8-encode
| From: | migueldiaz at gennio dot com | Date: | Wed, 14 Dec 2005 05:23:32 +0000 |
| Subject: | note 59710 added to function.utf8-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100105@lists.php.net to get a copy of this message | ||
Here's my function to know if one string is encoded in UTF8.
If we encode in UTF8 a string or text file that is already encoded in UTF8, it's expected to
find the character '' ( ALT+159) in the final string.
<?php
function isUTF8($string)
{
$string_utf8 = utf8_encode($string);
if( strpos($string_utf8,"",0) !== false ) // "" is ALT+159
return true; // the original string was utf8
else
return false; // otherwise
}
?>
regards
Miguel Díaz
----
Manual Page -- http://www.php.net/manual/en/function.utf8-encode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59710
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59710&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59710&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59710&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59710&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59710&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59710&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59710&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59710&report=yes
Search -- http://master.php.net/manage/user-notes.php