<?php /** * */ class Utf8 { function __construct() { global $CFG; if( preg_match('/./u', '') === 1 AND function_exists('iconv') AND ini_get('mbstring.func_overload') != 1 ) { define('UTF8_ENABLED', TRUE); if(extension_loaded('mbstring')) { define('MB_ENABLED', TRUE); mb_internal_encoding('UTF-8'); } } } function clean_string($str) { $str = @iconv('UTF-8', 'UTF-8//IGNOE', $str); return $str; } function convert_to_utf8($str, $encoding) { if(function_exists('iconv')) { $str = @iconv($encoding, 'UTF-8', $str); } elseif(function_exists('mb_convert_encoding')) { $str = @mb_convert_encoding($str, 'UTF-8', $encoding); } else { return FALSE; } return $str; } function _is_ascii($str) { return (preg_match('/[^\x00-\x7F]/S', $str)==0); } }