Bug #78979 [Nab]: Changing the encoding breaks the XML.

From: Date: Tue, 16 Jun 2020 07:13:59 +0000
Subject: Bug #78979 [Nab]: Changing the encoding breaks the XML.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227502@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78979&edit=1 ID: 78979 Updated by: cmb@php.net Reported by: vyfix at yahoo dot co dot jp Summary: Changing the encoding breaks the XML. Status: Not a bug Type: Bug Package: DOM XML related Operating System: Windows, Linux PHP Version: 7.4.0 Assigned To: cmb Block user comment: N Private report: N New Comment: Upstream bug report: <https://gitlab.gnome.org/GNOME/libxml2/-/issues/166>. Previous Comments: ------------------------------------------------------------------------ [2020-06-15 14:49:52] cmb@php.net Okay, I tracked that regression down to commit 407b393[1] in libxml2, so this is doesn't look like a bug in PHP. [1] <https://github.com/GNOME/libxml2/commit/407b393d8023a6f20422fb3bf5806cf15ab750ad> ------------------------------------------------------------------------ [2020-04-30 05:44:20] vyfix at yahoo dot co dot jp More short code: https://3v4l.org/d1SZQ My windows, linux output are ``` >php test.php Original size -> 100000 BIG-5 -> 4051 SHIFT-JIS -> 4047 SHIFT_JIS -> 4047 Shift_JIS -> 4047 UTF-8 -> 100000 ASCII -> 100000 ISO-8859-1 -> 100000 ``` ------------------------------------------------------------------------ [2020-02-29 10:13:40] cmb@php.net I can reproduce the reported behavior with PHP 7.3 on Windows (libxml 2.9.10), but not on Linux (libxml 2.9.4). This *might* be an upstream issue. ------------------------------------------------------------------------ [2020-02-28 23:34:16] beberlei@php.net Could you please add a simpler xml example? The one you gave is a bit unreadable. Would one tag suffice with a much smaller text content? ------------------------------------------------------------------------ [2019-12-19 12:22:29] drtechno at mail dot com Should be using mb_convert_encoding /* Convert UTF-8 to SHIFT_JIS */ $str = mb_convert_encoding($str, "SJIS", "UTF-8"); Just changing the attribute in the file will not change the encoding, and the backslash character that forms because the binary encoding isn't changed, some data is escaping. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=78979 -- Edit this bug report at https://bugs.php.net/bug.php?id=78979&edit=1

« previous php.bugs (#227502) next »