From e7b2a09acbea291c3d6266a35e98f1bb7b1e74d4 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Wed, 9 Sep 2009 05:06:11 +0300 Subject: [PATCH] Issue #306 - Upgrading HTMLPurifier's Encoder class, so it not to depend on iconv too much. The encoding conversion functions from the multibyte string library might help for dealing with some encodings even without iconv or mbstring. --- .../library/HTMLPurifier/Encoder.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main/inc/lib/htmlpurifier/library/HTMLPurifier/Encoder.php b/main/inc/lib/htmlpurifier/library/HTMLPurifier/Encoder.php index 5c4842e88f..e3e3db6697 100755 --- a/main/inc/lib/htmlpurifier/library/HTMLPurifier/Encoder.php +++ b/main/inc/lib/htmlpurifier/library/HTMLPurifier/Encoder.php @@ -288,6 +288,16 @@ class HTMLPurifier_Encoder restore_error_handler(); return $str; } + // Added Ivan Tcholakov, 09-SEP-2009. + // Next try - encoding conversion related functions form Dokeos LMS, + // for some encodings they work even without iconv or mbstring installed. + elseif (function_exists('api_is_encoding_supported')) { + if (api_is_encoding_supported($encoding)) { + $str = api_utf8_encode($str, $encoding); + restore_error_handler(); + return $str; + } + } trigger_error('Encoding not supported, please install iconv', E_USER_ERROR); } @@ -323,6 +333,16 @@ class HTMLPurifier_Encoder restore_error_handler(); return $str; } + // Added Ivan Tcholakov, 09-SEP-2009. + // Next try - encoding conversion related functions form Dokeos LMS, + // for some encodings they work even without iconv or mbstring installed. + elseif (function_exists('api_is_encoding_supported')) { + if (api_is_encoding_supported($encoding)) { + $str = api_utf8_decode($str, $encoding); + restore_error_handler(); + return $str; + } + } trigger_error('Encoding not supported', E_USER_ERROR); }