note 44843 deleted from function.utf8-encode by cmb
| From: | cmb@php.net | Date: | Sun, 22 Dec 2019 09:00:14 +0000 |
| Subject: | note 44843 deleted from function.utf8-encode by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213574@lists.php.net to get a copy of this message | ||
Note Submitter: steven -at- acko -dot- net
----
Note that you should only use utf8_encode() on ISO-8859-1 data, and not on data using the
Windows-1252 codepage. Microsoft's Windows-1252 codepage contains ISO-8859-1, but it includes
several characters in the range 0x80-0x9F whose codepoints in Unicode do not match the byte's
value (in Unicode, codepoints U+80 - U+9F are unassigned).
utf8_encode() simply assumes the bytes integer value is the codepoint number in Unicode.
E.g. in 1252, byte 0x80 is the euro sign, which is U+20AC. The same goes for curly quotes, em
dashes, etc.
utf8_encode() will convert 0x80 into U+0080 (an unassigned codepoint) rather than U+20AC.
To convert 1252 to UTF-8, use iconv, recode or mbstring.