/** * Set required encode and binary hash of most probably character in * selected language * * @param string $lang [en, fr, gr, it, sp, ar] Language profile selected * * @return object $this to build a fluent interface * @author Khaled Al-Sham'aa <*****@*****.**> */ public static function setLang($lang) { switch ($lang) { case 'en': self::$encode = ' etaoins'; break; case 'fr': self::$encode = ' enasriu'; break; case 'gr': self::$encode = ' enristu'; break; case 'it': self::$encode = ' eiaorln'; break; case 'sp': self::$encode = ' eaosrin'; break; default: self::$encode = iconv('utf-8', 'cp1256', ' الميوتة'); } self::$binary = '0000|0001|0010|0011|0100|0101|0110|0111|'; return $this; }
$rate = round($after * 100 / $before); echo "String size before was: $before Byte<br>"; echo "Compressed string size after is: $after Byte<br>"; echo "Rate $rate %<hr>"; $str = $obj->decompress($zip); $word = 'ÇáÏæá'; if ($obj->search($zip, $word)) { echo "Search for $word in zipped string and find it<hr>"; } else { echo "Search for $word in zipped string and do not find it<hr>"; } $len = ArCompressStr::length($zip); echo "Original length of zipped string is $len Byte<hr>"; echo '<div dir="rtl" align="justify">'.nl2br($str).'</div>'; ?> </div><br /> <div class="Paragraph"> <h2>Example Code:</h2> <?php highlight_string(<<<'END' <?php include('../Arabic.php'); $obj = new Arabic('ArCompressStr'); $obj->setInputCharset('windows-1256'); $obj->setOutputCharset('windows-1256');