Skip to content

Commit c953782

Browse files
author
Adam McCann
committed
Further fix for encoding issues (on JSON->HTML this time), CREO-148
1 parent d2d7be4 commit c953782

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/Components/EmbeddedComponent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ protected function appendHtml(stdClass $json, DOMDocument $dom, DOMElement $figu
7272
// create a temporary document and load the plain html
7373
$tmpDoc = new DOMDocument;
7474
libxml_use_internal_errors(true); // for html5 tags
75-
$tmpDoc->loadHTML("<html><body>$html</body></html>");
75+
$tmpDoc->loadHTML('<?xml encoding="UTF-8"><html><body>$html</body></html>');
76+
$tmpDoc->encoding = 'UTF-8';
7677
libxml_clear_errors();
7778

7879
// import and attach the created nodes to the paragraph

src/Components/Formats.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public function render()
108108

109109
// create a temporary document and load the plain html
110110
$tmpDoc = new DOMDocument;
111-
$tmpDoc->loadHTML('<html><body>' . $this->text . '</body></html>');
111+
$tmpDoc->loadHTML('<?xml encoding="UTF-8"><html><body>' . $this->text . '</body></html>');
112+
$tmpDoc->encoding = 'UTF-8';
112113

113114
// import and attach the created nodes to the paragraph
114115
foreach ($tmpDoc->getElementsByTagName('body')->item(0)->childNodes as $node) {

src/Components/HTMLComponent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public function parse(stdClass $json, DOMDocument $dom, DOMElement $parentElemen
4242

4343
// create a temporary document and load the plain html
4444
$tmpDoc = new DOMDocument;
45-
$tmpDoc->loadHTML('<html><body>' . $json->html . '</body></html>');
45+
$tmpDoc->loadHTML('<?xml encoding="UTF-8"><html><body>' . $json->html . '</body></html>');
46+
$tmpDoc->encoding = 'UTF-8';
4647

4748
// import and attach the created nodes to the paragraph
4849
foreach ($tmpDoc->getElementsByTagName('body')->item(0)->childNodes as $node) {

0 commit comments

Comments
 (0)