diff --git a/Classes/PHPExcel/Shared/String.php b/Classes/PHPExcel/Shared/String.php index 0b5f9553..3e495e82 100644 --- a/Classes/PHPExcel/Shared/String.php +++ b/Classes/PHPExcel/Shared/String.php @@ -443,10 +443,10 @@ class PHPExcel_Shared_String $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); } else { - $data = pack('vC', $ln, 0x08); + $data = pack('vC', $ln, 0x09); $data .= pack('v', count($arrcRuns)); // characters - $data .= $value; + $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); foreach ($arrcRuns as $cRun){ $data .= pack('v', $cRun['strlen']); $data .= pack('v', $cRun['fontidx']); diff --git a/Classes/PHPExcel/Writer/Excel5/Worksheet.php b/Classes/PHPExcel/Writer/Excel5/Worksheet.php index 730e7398..3983f74d 100644 --- a/Classes/PHPExcel/Writer/Excel5/Worksheet.php +++ b/Classes/PHPExcel/Writer/Excel5/Worksheet.php @@ -424,7 +424,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter if ($cVal instanceof PHPExcel_RichText) { // $this->_writeString($row, $column, $cVal->getPlainText(), $xfIndex); $arrcRun = array(); - $str_len = strlen($cVal->getPlainText()); + $str_len = PHPExcel_Shared_String::CountCharacters($cVal->getPlainText(), 'UTF-8'); $str_pos = 0; $elements = $cVal->getRichTextElements(); foreach ($elements as $element) { @@ -437,7 +437,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter } $arrcRun[] = array('strlen' => $str_pos, 'fontidx' => $str_fontidx); // Position FROM - $str_pos += strlen($element->getText()); + $str_pos += PHPExcel_Shared_String::CountCharacters($element->getText(), 'UTF-8'); } $this->_writeRichTextString($row, $column, $cVal->getPlainText(), $xfIndex, $arrcRun); } else { diff --git a/changelog.txt b/changelog.txt index 5ab739cb..6899e331 100644 --- a/changelog.txt +++ b/changelog.txt @@ -43,6 +43,7 @@ Fixed in develop branch: - Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't - Bugfix: (Progi1984) Work item GH-22 - Sheet View in Excel5 Writer - Bugfix: (amironov) Work item GH-82 - PHPExcel_Worksheet::getCellCollection() may not return last cached cell +- Bugfix: (teso) Work item 18551 - Rich Text containing UTF-8 characters creating unreadable content with Excel5 Writer --------------------------------------------------------------------------------