php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78979 Changing the encoding breaks the XML.
Submitted: 2019-12-17 12:44 UTC Modified: 2020-06-16 07:13 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: vyfix at yahoo dot co dot jp Assigned: cmb (profile)
Status: Not a bug Package: DOM XML related
PHP Version: 7.4.0 OS: Windows, Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vyfix at yahoo dot co dot jp
New email:
PHP Version: OS:

 

 [2019-12-17 12:44 UTC] vyfix at yahoo dot co dot jp
Description:
------------
Please see test script.

Test script:
---------------
<?php

const XML = '<?xml version="1.0" encoding="UTF-8"?>
<test>
    <test1>1400000000000000000000000000000000000000460000000000000000000000000000000000000046000000000000000000000000000000000000001E000000780000000000000000000000000000007800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test1>
    <test2>02000000020000000200000002000000000000000000000000000000</test2>
    <test3>1400000014000000000000000000000000000000460000004600000046000000000000000000000046000000460000008C0000000000000000000000460000008C000000B400000000000000000000008C000000B40000000000000000000000000000008C0000008C0000008C000000B400000000000000460000008C000000B40000000000000000000000460000008C000000B4000000B4000000000000008C0000008C000000B4000000FA000000000000008C000000B4000000B4000000B4000000FA0000008C000000B4000000FA000000FA00000000000000FA0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test3>
    <test4>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test4>
    <test5>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test5>
    <test6>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test6>
    <test7>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test7>
    <test8>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test8>
    <test9>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test9>
    <test10>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test10>
    <test11>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test11>
    <test12>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test12>
</test>';

libxml_use_internal_errors(true);
$dom = new DOMDocument();

$dom->loadXML(XML);

$dom->encoding = 'SHIFT_JIS';

$test = $xml = $dom->saveXML();

echo $test;


Expected result:
----------------
<?xml version="1.0" encoding="SHIFT_JIS"?>
<test>
    <test1>1400000000000000000000000000000000000000460000000000000000000000000000000000000046000000000000000000000000000000000000001E000000780000000000000000000000000000007800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test1>
    <test2>02000000020000000200000002000000000000000000000000000000</test2>
    <test3>1400000014000000000000000000000000000000460000004600000046000000000000000000000046000000460000008C0000000000000000000000460000008C000000B400000000000000000000008C000000B40000000000000000000000000000008C0000008C0000008C000000B400000000000000460000008C000000B40000000000000000000000460000008C000000B4000000B4000000000000008C0000008C000000B4000000FA000000000000008C000000B4000000B4000000B4000000FA0000008C000000B4000000FA000000FA00000000000000FA0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test3>
    <test4>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test4>
    <test5>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test5>
    <test6>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test6>
    <test7>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test7>
    <test8>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test8>
    <test9>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test9>
    <test10>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test10>
    <test11>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test11>
    <test12>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test12>
</test>

Actual result:
--------------
<?xml version="1.0" encoding="SHIFT_JIS"?>
<test>
    <test1>1400000000000000000000000000000000000000460000000000000000000000000000000000000046000000000000000000000000000000000000001E000000780000000000000000000000000000007800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test1>
    <test2>02000000020000000200000002000000000000000000000000000000</test2>
    <test3>1400000014000000000000000000000000000000460000004600000046000000000000000000000046000000460000008C0000000000000000000000460000008C000000B400000000000000000000008C000000B40000000000000000000000000000008C0000008C0000008C000000B400000000000000460000008C000000B40000000000000000000000460000008C000000B4000000B4000000000000008C0000008C000000B4000000FA000000000000008C000000B4000000B4000000B4000000FA0000008C000000B4000000FA000000FA00000000000000FA0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test3>
    <test4>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test4>
    <test5>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test5>
    <test6>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000</test6>
    <test7>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test7>
    <test8>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test8>
    <test9>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test9>
    <test10>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test10>
    <test11>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test11>
    <test12>00000000000000000000000000000000000000000000000000000000E80300004C040000E8030000E80300006C0700004C0400004C04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C150000AC0D0000AC0D0000AC0D0000AC0D0000AC0D0000AC0D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</test12>
</test>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-19 12:22 UTC] 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.
 [2020-02-28 23:34 UTC] 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?
 [2020-02-29 10:13 UTC] 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-04-30 05:44 UTC] 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-06-15 14:49 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-06-15 14:49 UTC] 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-06-16 07:13 UTC] cmb@php.net
Upstream bug report: <https://gitlab.gnome.org/GNOME/libxml2/-/issues/166>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 02:01:30 2024 UTC