/** * Converts a string into utf-8 if necessary */ public function toUtf8($str) { if (strcasecmp(Dataproxy::encoding(), 'utf-8') !== 0) { if (is_callable('mb_convert_encoding')) { $str = mb_convert_encoding($str, 'utf-8', Dataproxy::encoding()); } else { if (is_callable('iconv')) { $str = iconv(Dataproxy::encoding(), 'utf-8', $str); } else { if (strcasecmp(Dataproxy::encoding(), 'iso-8859-1') === 0 and is_callable('utf8_encode')) { $str = utf8_encode($str); } else { COM_errorLog('Dataproxy: Error! No way to convert data into UTF-8.'); } } } } return $str; }