note 123736 added to function.trim

From: Date: Thu, 04 Apr 2019 11:02:28 +0000
Subject: note 123736 added to function.trim
Groups: php.notes 
Request: Send a blank email to php-notes+get-210518@lists.php.net to get a copy of this message
It is worth mentioning that trim, ltrim and rtrim are NOT multi-byte safe, meaning that trying to remove an utf-8 encoded non-breaking space for instance will result in the destruction of utf-8 characters than contain parts of the utf-8 encoded non-breaking space, for instance: non breaking-space is "\u{a0}" or "\xc2\xa0" in utf-8, "µ" is "\u{b5}" or "\xc2\xb5" in utf-8 and "à" is "\u{e0}" or "\xc3\xa0" in utf-8 $input = "\u{a0}µ déjà\u{a0}"; // " µ déjà " $output = trim($input, "\u{a0}"); // "▒ déj▒" or whatever how the interpretation of broken utf-8 characters is performed $output got both "\u{a0}" characters removed but also both "µ" and "à" characters destroyed ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.194 (proxied: 82.235.99.5) ---- Manual Page -- http://php.net/manual/en/function.trim.php Edit -- https://master.php.net/note/edit/123736 Del: integrated -- https://master.php.net/note/delete/123736/integrated Del: useless -- https://master.php.net/note/delete/123736/useless Del: bad code -- https://master.php.net/note/delete/123736/bad+code Del: spam -- https://master.php.net/note/delete/123736/spam Del: non-english -- https://master.php.net/note/delete/123736/non-english Del: in docs -- https://master.php.net/note/delete/123736/in+docs Del: other reasons-- https://master.php.net/note/delete/123736 Reject -- https://master.php.net/note/reject/123736 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#210518) next »