Skip to content
Snippets Groups Projects
Commit baf36407 authored by Jared Hancock's avatar Jared Hancock
Browse files

Better converting from ticket thread to PDF

Assume that text in the database is encoded in UTF-8 and assume that it is
HTML text and the entities should be decoded prior to display in the PDF.

Fixes #756
parent ec694ffa
No related branches found
No related tags found
No related merge requests found
...@@ -91,11 +91,21 @@ class Ticket2PDF extends FPDF ...@@ -91,11 +91,21 @@ class Ticket2PDF extends FPDF
} }
function _utf8($text) { function _utf8($text) {
// Assume text is in utf-8 charset
$flags = ENT_COMPAT;
if (phpversion() >= '5.4.0')
$flags |= ENT_HTML401;
if(function_exists('iconv')) // Assume text in the database is HTML
$text = html_entity_decode($text, $flags, 'UTF-8');
if (function_exists('iconv'))
return iconv('UTF-8', 'windows-1252', $text); return iconv('UTF-8', 'windows-1252', $text);
elseif (function_exists('utf8_decode'))
return utf8_decode($text);
return utf8_encode($text); // XXX: FPDF does not support UTF-8 encoding
return $text;
} }
function _print() { function _print() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment