/** * The singleton method * * @return object Instance of this class * * @author Khaled Al-Sham'aa <*****@*****.**> */ public static function singleton() { // if (!(self::$_instance instanceof self)) { if (!isset(self::$_instance)) { $c = __CLASS__; self::$_instance = new $c(); } return self::$_instance; }
/** * Convert Arabic string from one charset to another * * @param string $str Original Arabic string that you would like * to convert * @param string $inputCharset Input charset * @param string $outputCharset Output charset * * @return string Converted Arabic string in defined charset * @author Khaled Al-Shamaa <*****@*****.**> */ public function coreConvert($str, $inputCharset, $outputCharset) { if ($inputCharset != $outputCharset) { if ($inputCharset == 'windows-1256') { $inputCharset = 'cp1256'; } if ($outputCharset == 'windows-1256') { $outputCharset = 'cp1256'; } $convStr = iconv($inputCharset, "{$outputCharset}", $str); if ($convStr == '' && $str != '') { include self::getClassFile('CharsetC'); $c = I18N_Arabic_CharsetC::singleton(); if ($inputCharset == 'cp1256') { $convStr = $c->win2utf($str); } else { $convStr = $c->utf2win($str); } } } else { $convStr = $str; } return $convStr; }