note 103860 added to function.iconv
| From: | marc at NOSPAM dot leftek dot com | Date: | Sat, 07 May 2011 05:02:43 +0000 |
| Subject: | note 103860 added to function.iconv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179517@lists.php.net to get a copy of this message | ||
A simple cleaning function [eg: iconv("UTF-8","UTF-8//IGNORE", $s)] may not be
enough when receiving UTF8 input that needs to be saved in MySQL. Prior to MySQL v5.5 four byte
sequences were not supported so a function is needed to strip these out as well:
<?php
for($pos=strlen($strUtf8)-1; $pos >= 0 ; $pos--){
$char = substr($strUtf8, $pos, 1);
if (ord($char) > 0xEF) $strUtf8 = substr($strUtf8, 0, $pos).substr($strUtf8,
$pos+1);
}
?>
----
Server IP: 222.73.207.145
Probable Submitter: 127.0.0.1 (proxied: 124.78.36.153)
----
Manual Page -- http://www.php.net/manual/en/function.iconv.php
Edit -- https://master.php.net/note/edit/103860
Del: integrated -- https://master.php.net/note/delete/103860/integrated
Del: useless -- https://master.php.net/note/delete/103860/useless
Del: bad code -- https://master.php.net/note/delete/103860/bad+code
Del: spam -- https://master.php.net/note/delete/103860/spam
Del: non-english -- https://master.php.net/note/delete/103860/non-english
Del: in docs -- https://master.php.net/note/delete/103860/in+docs
Del: other reasons-- https://master.php.net/note/delete/103860
Reject -- https://master.php.net/note/reject/103860
Search -- https://master.php.net/manage/user-notes.php