+/**
+ * @param string $str
+ * @param string $to_encoding
+ * @param string $from_encoding
+ * @param string $default_charset
+ * @return string
+ */
+function sqimap_mb_convert_encoding($str, $to_encoding, $from_encoding, $default_charset)
+{
+ // Allows mbstring functions only with iso-8859-*, utf-8 and
+ // iso-2022-jp (Japanese)
+ // koi8-r and gb2312 can be added only in php 4.3+
+ if ( stristr($default_charset, 'iso-8859-') ||
+ stristr($default_charset, 'utf-8') ||
+ stristr($default_charset, 'iso-2022-jp') ) {
+ if (function_exists('mb_convert_encoding')) {
+ return mb_convert_encoding($str, $to_encoding, $from_encoding);
+ }
+ }
+ return '';
+}
+