Bug #79122 [Opn->Nab]: mb_convert_encoding doesn't convert properly to UTF-16

From: Date: Wed, 15 Jan 2020 17:30:37 +0000
Subject: Bug #79122 [Opn->Nab]: mb_convert_encoding doesn't convert properly to UTF-16
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224917@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79122&edit=1 ID: 79122 Updated by: nikic@php.net Reported by: pascu dot vlad at gmail dot com Summary: mb_convert_encoding doesn't convert properly to UTF-16 -Status: Open +Status: Not a bug Type: Bug Package: Unicode Engine related Operating System: Irrelevant PHP Version: Irrelevant Block user comment: N Private report: N New Comment: You are not passing 'UTF-16' as the $encoding parameter, so all your strings are interpreted as UTF-8. Previous Comments: ------------------------------------------------------------------------ [2020-01-15 17:28:46] pascu dot vlad at gmail dot com Description: ------------ mb_convert_encoding seems to not produce correct results when dealing with higher Unicode characters. When supplying UTF-8 encoded strings,, the mb_* functions return all valid results for characters count, code point and byte count. However, after converting to UTF-16, the whole string is mangled. I have attached 4 links with relevant examples. Test script: --------------- https://3v4l.org/LQott https://3v4l.org/DrEcL https://3v4l.org/acOTR https://3v4l.org/5VXFC Expected result: ---------------- Correct result for total length (number of characters) and each character (code point + byte count) in both encodings, as documented here (links in order with code examples): https://www.iemoji.com/view/emoji/885/smileys-people/grinning-face https://www.iemoji.com/view/emoji/1659/flags/romania https://www.iemoji.com/view/emoji/1379/skin-tones/baby-light-skin-tone https://www.iemoji.com/view/emoji/306/symbols/hash-key Actual result: -------------- Correct result only for the supplied UTF-8 string and no valid results for any of the converted strings. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79122&edit=1

« previous php.bugs (#224917) next »