note 101871 added to function.iconv

From: Date: Sat, 15 Jan 2011 00:17:21 +0000
Subject: note 101871 added to function.iconv
Groups: php.notes 
Request: Send a blank email to php-notes+get-175773@lists.php.net to get a copy of this message
I have used iconv to convert from cp1251 into UTF-8. I spent a day to investigate why a string with Russian capital 'Р' (sounds similar to 'r') at the end cannot be inserted into a database. The problem is not in iconv. But 'Р' in cp1251 is chr(208) and 'Р' in UTF-8 is chr(208).chr(106). chr(106) is one of the space symbol which match '\s' in regex. So, it can be taken by a greedy '+' or '*' operator. In that case, you loose 'Р' in your string. For example, 'ГР ' (Russian, UTF-8). Function preg_match. Regex is '(.+?)[\s]*'. Then '(.+?)' matches 'Г'.chr(208) and '[\s]*' matches chr(106).' '. Although, it is not a bug of iconv, but it looks like it very much. That's why I put this comment here. ---- Server IP: 69.147.83.197 Probable Submitter: 109.205.254.66 ---- Manual Page -- http://www.php.net/manual/en/function.iconv.php Edit -- https://master.php.net/note/edit/101871 Del: integrated -- https://master.php.net/note/delete/101871/integrated Del: useless -- https://master.php.net/note/delete/101871/useless Del: bad code -- https://master.php.net/note/delete/101871/bad+code Del: spam -- https://master.php.net/note/delete/101871/spam Del: non-english -- https://master.php.net/note/delete/101871/non-english Del: in docs -- https://master.php.net/note/delete/101871/in+docs Del: other reasons-- https://master.php.net/note/delete/101871 Reject -- https://master.php.net/note/reject/101871 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175773) next »