Forum


Replies: 1   Views: 6125
Problem with encoding utf-8 in embedhtml
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by Berik  · 05-09-2017 - 08:55

After adding HTML elements with cyrillic text in docx file i’m getting next result(output): 

 «Ð еалÑŒнÑ‹е заÑ€платы казаÑÂ…ÑÂÑ‚анцев до ÑÂиÑÂ… поÑ€ пÑ€одолжаÑÂŽÑ‚ обеÑÂцениваÑ‚ÑÂŒÑÂÑÂ, пÑ€ичем ÑÂтремиÑ‚елÑŒно.Падение уÑÂкоÑ€илоÑÂÑÂŒ еще в начале леÑ‚а. Однако, еÑÂли веÑ€иÑ‚ÑÂŒ даннÑ‹м аналиÑ‚иков EnergyProm, за шеÑÂÑ‚ÑÂŒ меÑÂÑÂцев 2017 ÑÂÑ€еднÑÂÑ заÑ€плаÑ‚а по ÑÂтране ÑÂоÑÂÑ‚авила почти 145 тыÑÂÑÂч Ñ‚енге, и ÑÂÑ‚о доволÑŒно неплоÑ…аÑ ÑÂумма.»

But text in addText method working good, until enable method setEncodeUTF8. Then both methods (addText and embedHTML) returning broken text 
$docx = new CreateDocx();
//$docx->setEncodeUTF8();
$docx->setDefaultFont('Times New Roman');
$docx->addText('Реальные зарплаты казахÑтанцев до Ñих пор');

$text = '<p>«Реальные зарплаты казахÑтанцев до Ñих пор продолжают обеÑцениватьÑÑ, причем Ñтремительно.Падение уÑкорилоÑÑŒ еще в начале лета. Однако, еÑли верить данным аналитиков EnergyProm, за шеÑть меÑÑцев 2017 ÑреднÑÑ Ð·Ð°Ñ€Ð¿Ð»Ð°Ñ‚Ð° по Ñтране ÑоÑтавила почти 145 тыÑÑч тенге, и Ñто довольно Ð½ÐµÐ¿Ð»Ð¾Ñ…Ð°Ñ Ñумма.»</p> <p>asdklaskdl sakldkl;sakdl ksal;dkl;asdkwqoeiowq wwqklsakdlsakldla; - s sadowqieowq ioepwqwoiepwqeiopwqeio wqeiowiqeowqeiopwepioweqpioweiopweqiopwqeiop wwiqoe oipe opiwqeiowqe & iopwqeiopw qwqewq.</p>';
$text = htmlspecialchars_decode($text);

$text .= '<ul><li>asddasd</li><li>Chudesaaaaa</li></ul>';
$paragraphOptions = array(
    'bold' => true,
    'font' => 'Arial'
);
$docx->embedHTML($text);
$docx->createDocx('example_addText_5');
Version:2017.02.20 (trial)