From 6ebd2c691b2dcd883e98cf467a792408349bbf59 Mon Sep 17 00:00:00 2001 From: moodler <moodler> Date: Wed, 28 Apr 2004 14:18:25 +0000 Subject: [PATCH] Uses iconv by default to convert texts into UTF-8 to keep GD happier. --- lib/graphlib.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/graphlib.php b/lib/graphlib.php index 4528577c46..43029e421f 100644 --- a/lib/graphlib.php +++ b/lib/graphlib.php @@ -162,6 +162,17 @@ function init() { } else { $this->parameter['lang_decode'] = ""; } + + $this->parameter['lang_transcode'] = ''; /// by default + + if (function_exists('iconv')) { + $charset = strtolower(get_string('thischarset')); + + if ($charset != 'iso-8859-1' and $charset != 'utf-8') { + $this->parameter['lang_transcode'] = $charset; + } + } + /// End Moodle mods @@ -1224,6 +1235,9 @@ function print_TTF($message) { if ($this->parameter['lang_decode']) { // Moodle addition include_once($this->parameter['lang_decode']); $text = lang_decode($text); + + } else if ($this->parameter['lang_transcode']) { + $text = iconv($this->parameter['lang_transcode'], 'UTF-8', $text); } ImageTTFText($this->image, $points, $angle, $x, $y, $colour, $font, $text); } @@ -1330,6 +1344,9 @@ function get_boundaryBox($message) { if ($this->parameter['lang_decode']) { // Moodle addition include_once($this->parameter['lang_decode']); $text = lang_decode($text); + + } else if ($this->parameter['lang_transcode']) { + $text = iconv($this->parameter['lang_transcode'], 'UTF-8', $text); } $bounds = ImageTTFBBox($points, $angle, $font, $text); -- 2.39.5