diff --git a/lib/html2text/lib.php b/lib/html2text/lib.php index 8df48d6506d..18972d4c700 100644 --- a/lib/html2text/lib.php +++ b/lib/html2text/lib.php @@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/html2text/Html2Text.php'); +require_once(__DIR__ . '/override.php'); /** * Wrapper for Html2Text diff --git a/lib/html2text/override.php b/lib/html2text/override.php new file mode 100644 index 00000000000..e7409458534 --- /dev/null +++ b/lib/html2text/override.php @@ -0,0 +1,58 @@ +. + +/** + * Wrapper for Html2Text + * + * This wrapper allows us to modify the upstream library without hacking it too much. + * + * @package core + * @copyright 2015 Andrew Nicols + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace Html2Text { + function mb_internal_encoding($encoding = null) { + static $internalencoding = 'utf-8'; + if ($encoding !== null) { + $internalencoding = $encoding; + return true; + } else { + return $internalencoding; + } + } + + function mb_substr($str, $start, $length, $encoding = null) { + if ($encoding === null) { + $encoding = mb_internal_encoding(); + } + return \core_text::substr($str, $start, $length, $encoding); + } + + function mb_strlen($str, $encoding = null) { + if ($encoding === null) { + $encoding = mb_internal_encoding(); + } + return \core_text::strlen($str, $encoding); + } + + function mb_strtolower($str, $encoding = null) { + if ($encoding === null) { + $encoding = mb_internal_encoding(); + } + return \core_text::strtolower($str, $encoding); + } +}