diff --git a/lib/html2text.php b/lib/html2text.php index c89be0ca300..8d143bfb297 100644 --- a/lib/html2text.php +++ b/lib/html2text.php @@ -580,9 +580,7 @@ class html2text */ function _strtoupper($str) { - if (function_exists('mb_strtoupper')) - return mb_strtoupper($str); - else - return strtoupper($str); + $tl = textlib_get_instance(); + return $tl->strtoupper($str); } } diff --git a/lib/html2text_readme.txt b/lib/html2text_readme.txt index b516e85b4bf..7fcaef1b3e7 100644 --- a/lib/html2text_readme.txt +++ b/lib/html2text_readme.txt @@ -30,6 +30,26 @@ index b7e3e3e..96ef508 100644 } } - -- Tim Hunt 2010-08-04 +-- Tim Hunt 2010-08-04 -2- No strip slashes, we do not use magic quotes any more in Moodle 2.0 or later \ No newline at end of file +2- No strip slashes, we do not use magic quotes any more in Moodle 2.0 or later + +3- Use textlib, not crappy functions that break UTF-8, in the _strtoupper method. + +Index: lib/html2text.php +--- lib/html2text.php 2 Sep 2010 12:49:29 -0000 1.16 ++++ lib/html2text.php 2 Nov 2010 19:57:09 -0000 +@@ -580,9 +580,7 @@ + */ + function _strtoupper($str) + { +- if (function_exists('mb_strtoupper')) +- return mb_strtoupper($str); +- else +- return strtoupper($str); ++ $tl = textlib_get_instance(); ++ return $tl->strtoupper($str); + } + } + +-- Tim Hunt 2010-11-02 diff --git a/lib/simpletest/testweblib.php b/lib/simpletest/testweblib.php index b7893013d09..7f9b000e6d6 100644 --- a/lib/simpletest/testweblib.php +++ b/lib/simpletest/testweblib.php @@ -128,6 +128,10 @@ class web_test extends UnitTestCase { $this->assertEqual($long, html_to_text($long, 0)); } + public function test_html_to_text_dont_screw_up_utf8() { + $this->assertEqual("\n\nAll the WORLD’S a stage.", html_to_text('

All the world’s a stage.

')); + } + public function test_clean_text() { $text = "lala xx"; $this->assertEqual($text, clean_text($text, FORMAT_PLAIN));