When I try to write UTF-8 Strings into an XML file using DomDocument it actually writes the hexadecimal notation of the string instead of the string itself.
for example:
ירושלים
instead of: ???????
any ideas how to resolve the issue?
Ok, here you go:
will work fine, because in this case, the document you constructed will retain the encoding specified as the second argument:
However, once you load XML into a Document that does not specify an encoding, you will lose anything you declared in the constructor, which means:
will not have an encoding of utf-8:
So if you loadXML something, make sure it is
and it will work as expected.
As an alternative, you can also specify the encoding after loading the document.