note 127968 added to function.mb-convert-encoding
| From: | JulianEgelstaff at main dot php dot net | Date: | Tue, 29 Nov 2022 07:15:21 +0000 |
| Subject: | note 127968 added to function.mb-convert-encoding | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219924@lists.php.net to get a copy of this message | ||
If you have what looks like ISO-8859-1, but it includes "smart quotes" courtesy of
Microsoft software, or people cutting and pasting content from Microsoft software, then what
you're actually dealing with is probably Windows-1252. Try this:
<?php
$cleanText = mb_convert_encoding($text, 'UTF-8', 'Windows-1252');
?>
The annoying part is that the auto detection (ie: the mb_detect_encoding function) will often think
Windows-1252 is ISO-8859-1. Close, but no cigar. This is critical if you're then trying to do
unserialize on the resulting text, because the byte count of the string needs to be perfect.
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.159.161 (proxied: 142.114.226.212)
----
Manual Page -- https://php.net/manual/en/function.mb-convert-encoding.php
Edit -- https://main.php.net/note/edit/127968
Del: integrated -- https://main.php.net/note/delete/127968/integrated
Del: useless -- https://main.php.net/note/delete/127968/useless
Del: bad code -- https://main.php.net/note/delete/127968/bad+code
Del: spam -- https://main.php.net/note/delete/127968/spam
Del: non-english -- https://main.php.net/note/delete/127968/non-english
Del: in docs -- https://main.php.net/note/delete/127968/in+docs
Del: other reasons-- https://main.php.net/note/delete/127968
Reject -- https://main.php.net/note/reject/127968
Search -- https://main.php.net/manage/user-notes.php