/** * Convert Arabic string from one charset to another * * @param string $str Original Arabic string that you wouldliketo 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'; } $conv_str = iconv($inputCharset, "{$outputCharset}//TRANSLIT", $str); if ($conv_str == '' && $str != '') { include_once $this->_path . '/ArCharsetC.class.php'; $c = ArCharsetC::singleton(); if ($inputCharset == 'cp1256') { $conv_str = $c->win2utf($str); } else { $conv_str = $c->utf2win($str); } } } else { $conv_str = $str; } return $conv_str; }
/** * 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_once self::getClassFile('ArCharsetC'); $c = ArCharsetC::singleton(); if ($inputCharset == 'cp1256') { $convStr = $c->win2utf($str); } else { $convStr = $c->utf2win($str); } } } else { $convStr = $str; } return $convStr; }