function readlineLeumi($line, $account) { //leumi wtf??? //if(strlen($line)==56) // return false; $refnum = ltrim(substr($line, 0, 7), '0'); if ($refnum > 0) { $bank = new Bankbook(); $bank->account_id = $account; $bank->refnum = $refnum; //ltrim(substr($line,22,7),' '); $bank->details = iconv("ISO-8859-8", "utf-8", hebrev(iconv("ibm862", "ISO-8859-8", substr($line, 16, 14)))); $bank->date = "20" . substr($line, 12, 2) . "-" . substr($line, 10, 2) . "-" . substr($line, 8, 2); $sighn = substr($line, 32, 1) . '1'; $value = ltrim(substr($line, 33, 12), '0 ') * $sighn; $bank->sum = $value; //$zachot-$hova; $sighn = substr($line, 46, 1) . '1'; $bank->total = ltrim(substr($line, 47, 12), '0 ') * $sighn; if (!$bank->searchBankbook()) { //mybe save output? num $bank->extCorrelation = 0; return $bank->save(); } } }
public static function heb_iso2uni($isoline) { $isoline = hebrev($isoline); $o = ''; $n = strlen($isoline); for ($i = 0; $i < $n; $i++) { $c = ord(substr($isoline, $i, 1)); $o .= $c > 223 && $c < 251 ? '&#' . (1264 + $c) . ';' : chr($c); } return utf8_encode($o); }
<p class=MsoNormal ><span lang=HE style='font-family:"Arial","sans-serif"'> </span></p> <p class=MsoNormal align=center style='text-align:right'><b><span lang=HE style='font-family:"Arial","sans-serif"'>כתובת </span></b><span lang=HE style='font-family:"Arial","sans-serif"'> </span><span lang=HE dir=RTL style='font-family:"Arial","sans-serif";direction: ltr;' ><?php echo hebrev($asset['street'] . ', ' . $asset['city']); ?> </span></p> <p class=MsoNormal align=center style='text-align:right'><b><span lang=HE style='font-family:"Arial","sans-serif"'>אזור תעסוקה</span></b><span lang=HE style='font-family:"Arial","sans-serif"'> </span><span lang=HE dir=RTL style="direction: ltr;"><?php echo hebrev($asset['employmentRegion']); ?> </span></p> <p class=MsoNormal align=center style='text-align:right'><b><span lang=HE style='font-family:"Arial","sans-serif"'>שנת הקמה</span></b><span lang=HE style='font-family:"Arial","sans-serif"'> </span><span dir=LTR><?php echo $asset['establishmentDate']; ?> </span></p> <p class=MsoNormal align=center style='text-align:right'><b><span lang=HE style='font-family:"Arial","sans-serif"'>בעלים </span></b><span lang=HE style='font-family:"Arial","sans-serif"'> </span><span lang=HE dir="ltr" style="direction: ltr;"><? foreach($investors as $investor) {
var_dump(htmlentities("Â ", ENT_COMPAT, "")); var_dump(htmlentities("Â ", ENT_COMPAT, "UTF-8")); var_dump(quoted_printable_encode("egfe \r\t")); var_dump(quoted_printable_decode("=65=67=66=65=")); var_dump(convert_uudecode("+22!L;W9E(%!(4\"\$`\n`")); var_dump(convert_uuencode("test\ntext text\r\n")); var_dump(str_rot13("PHP 4.3.0")); var_dump(crc32("The quick brown fox jumped over the lazy dog.")); var_dump(strlen(crypt("mypassword"))); var_dump(md5("apple")); var_dump(sha1("apple")); $trans = array("hello" => "hi", "hi" => "hello"); var_dump(strtr("hi all, I said hello", $trans)); var_dump(convert_cyr_string("abc", "a", "d")); // sanity var_dump(hebrev("test")); // sanity var_dump(hebrevc("test")); // sanity var_dump(nl_langinfo(AM_STR)); var_dump(sprintf("A%sB%dC", "test", 10)); var_dump(sprintf("%010s", "1101")); var_dump(sprintf("%02d", "09")); var_dump(sprintf("(%s-%s)", "foobar", "barfoo")); var_dump(sprintf("[%s]", "ab")); var_dump(vsprintf("A%sB%dC", array("test", 10))); var_dump(sscanf("SN/2350001", "SN/%d")); var_dump(sscanf("SN/2350001", "SN/%d", $out)); var_dump($out); var_dump(chr(92)); var_dump(ord("\\"));
* Description: Convert logical Hebrew text to visual text * Source code: ext/standard/string.c */ echo "*** Testing hebrev() function: with unexpected inputs for 'hebrew_text' argument ***\n"; //get an unset variable $unset_var = 'string_val'; unset($unset_var); //defining a class class sample { public function __toString() { return "sample object"; } } //getting the resource $file_handle = fopen(__FILE__, "r"); // array with different values for $hebrew_text $texts = array(0, 1, 255, 256, 2147483647, -2147483648, 10.5, -20.5, 1012345.67, array(), array(0), array(1, 2), true, false, TRUE, FALSE, NULL, null, new sample(), $file_handle, @$undefined_var, @$unset_var, 'text with parentheses (', 'text with parentheses )', 'text with bracket [', 'text with bracket ]', 'text with curly bracket {', 'text with curly bracket }', 'text with backslash escape \\', 'text with a slash char /', 'text with a greater than char >', 'text with a less than char <'); // loop through with each element of the $texts array to test hebrev() function $count = 1; foreach ($texts as $hebrew_text) { echo "-- Iteration {$count} --\n"; var_dump(hebrev($hebrew_text)); $count++; } fclose($file_handle); //closing the file handle ?> ===DONE===
/** * Recode a string to UTF-8 * * If the encoding is not supported, the string is returned as-is * * @param string $string Original string * @param string $encoding Original encoding (lowered) * @return string The string, encoded in UTF-8 */ function utf8_recode($string, $encoding) { $encoding = strtolower($encoding); if ($encoding == 'utf-8' || !is_string($string) || empty($string)) { return $string; } // we force iso-8859-1 to be cp1252 if ($encoding == 'iso-8859-1') { $encoding = 'cp1252'; } // convert iso-8859-8-i to iso-8859-8 else if ($encoding == 'iso-8859-8-i') { $encoding = 'iso-8859-8'; $string = hebrev($string); } // First, try iconv() if (function_exists('iconv')) { $ret = @iconv($encoding, 'utf-8', $string); if (!empty($ret)) { return $ret; } } // Try the mb_string extension if (function_exists('mb_convert_encoding')) { // mbstring is nasty on PHP4, we must make *sure* that we send a good encoding switch ($encoding) { case 'iso-8859-1': case 'iso-8859-2': case 'iso-8859-4': case 'iso-8859-7': case 'iso-8859-9': case 'iso-8859-15': case 'windows-1251': case 'windows-1252': case 'cp1252': case 'shift_jis': case 'euc-kr': case 'big5': case 'gb2312': $ret = @mb_convert_encoding($string, 'utf-8', $encoding); if (!empty($ret)) { return $ret; } } } // Try the recode extension if (function_exists('recode_string')) { $ret = @recode_string($encoding . '..utf-8', $string); if (!empty($ret)) { return $ret; } } // If nothing works, check if we have a custom transcoder available if (!preg_match('#^[a-z0-9_ \\-]+$#', $encoding)) { // Make sure the encoding name is alphanumeric, we don't want it to be abused into loading arbitrary files trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); } // iso-8859-* character encoding if (preg_match('/iso[_ -]?8859[_ -]?(\\d+)/', $encoding, $array)) { switch ($array[1]) { case '1': case '2': case '4': case '7': case '8': case '9': case '15': if (!function_exists('iso_8859_' . $array[1])) { if (!file_exists(IP_ROOT_PATH . 'includes/utf/data/recode_basic.' . PHP_EXT)) { trigger_error('Basic reencoder file is missing', E_USER_ERROR); } include(IP_ROOT_PATH . 'includes/utf/data/recode_basic.' . PHP_EXT); } return call_user_func('iso_8859_' . $array[1], $string); break; default: trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); break; } } // CP/WIN character encoding if (preg_match('/(?:cp|windows)[_\- ]?(\\d+)/', $encoding, $array)) { switch ($array[1]) { case '932': break; case '1250': case '1251': case '1252': case '1254': case '1255': case '1256': case '1257': case '874': if (!function_exists('cp' . $array[1])) { if (!file_exists(IP_ROOT_PATH . 'includes/utf/data/recode_basic.' . PHP_EXT)) { trigger_error('Basic reencoder file is missing', E_USER_ERROR); } include(IP_ROOT_PATH . 'includes/utf/data/recode_basic.' . PHP_EXT); } return call_user_func('cp' . $array[1], $string); break; default: trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); break; } } // TIS-620 if (preg_match('/tis[_ -]?620/', $encoding)) { if (!function_exists('tis_620')) { if (!file_exists(IP_ROOT_PATH . 'includes/utf/data/recode_basic.' . PHP_EXT)) { trigger_error('Basic reencoder file is missing', E_USER_ERROR); } include(IP_ROOT_PATH . 'includes/utf/data/recode_basic.' . PHP_EXT); } return tis_620($string); } // SJIS if (preg_match('/sjis(?:[_ -]?win)?|(?:cp|ibm)[_ -]?932|shift[_ -]?jis/', $encoding)) { if (!function_exists('sjis')) { if (!file_exists(IP_ROOT_PATH . 'includes/utf/data/recode_cjk.' . PHP_EXT)) { trigger_error('CJK reencoder file is missing', E_USER_ERROR); } include(IP_ROOT_PATH . 'includes/utf/data/recode_cjk.' . PHP_EXT); } return sjis($string); } // EUC_KR if (preg_match('/euc[_ -]?kr/', $encoding)) { if (!function_exists('euc_kr')) { if (!file_exists(IP_ROOT_PATH . 'includes/utf/data/recode_cjk.' . PHP_EXT)) { trigger_error('CJK reencoder file is missing', E_USER_ERROR); } include(IP_ROOT_PATH . 'includes/utf/data/recode_cjk.' . PHP_EXT); } return euc_kr($string); } // BIG-5 if (preg_match('/big[_ -]?5/', $encoding)) { if (!function_exists('big5')) { if (!file_exists(IP_ROOT_PATH . 'includes/utf/data/recode_cjk.' . PHP_EXT)) { trigger_error('CJK reencoder file is missing', E_USER_ERROR); } include(IP_ROOT_PATH . 'includes/utf/data/recode_cjk.' . PHP_EXT); } return big5($string); } // GB2312 if (preg_match('/gb[_ -]?2312/', $encoding)) { if (!function_exists('gb2312')) { if (!file_exists(IP_ROOT_PATH . 'includes/utf/data/recode_cjk.' . PHP_EXT)) { trigger_error('CJK reencoder file is missing', E_USER_ERROR); } include(IP_ROOT_PATH . 'includes/utf/data/recode_cjk.' . PHP_EXT); } return gb2312($string); } // Trigger an error?! Fow now just give bad data :-( trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); //return $string; // use utf_normalizer::cleanup() ? }
<?php /* Prototype : string hebrev ( string $hebrew_text [, int $max_chars_per_line ] ) * Description: Convert logical Hebrew text to visual text * Source code: ext/standard/string.c */ echo "*** Testing hebrev() : basic functionality ***\n"; $hebrew_text = "The hebrev function converts logical Hebrew text to visual text.\nThe function tries to avoid breaking words.\n"; var_dump(hebrev($hebrew_text)); var_dump(hebrev($hebrew_text, 15)); ?> ===DONE===
<HTML> <HEAD> <TITLE>hebrev</TITLE> </HEAD> <BODY> <?php print hebrev("Hebrew"); ?> </BODY> </HTML>
/** * @param null $max_chars_per_line * @return $this * @desc 把希伯来文本从右至左的流转换为左至右的流。 */ public function hebrev($max_chars_per_line = null) { $this->current = hebrev($this->current, $max_chars_per_line); return $this; }
* Source code: ext/standard/string.c */ echo "*** Testing hebrev() function: with unexpected inputs for 'max_chars_per_line' argument ***\n"; //get an unset variable $unset_var = 'string_val'; unset($unset_var); //defining a class class sample { public function __toString() { return "sample object"; } } //getting the resource $file_handle = fopen(__FILE__, "r"); // array with different values for $max_chars_per_line $inputs = array(0, 1, 255, 256, 2147483647, -2147483648, 10.5, -20.5, 1012345.67, array(), array(0), array(1, 2), true, false, TRUE, FALSE, NULL, null, "abc", 'abc', "3abc", "0abc", "0x3", new sample(), $file_handle, @$undefined_var, @$unset_var); // loop through with each element of the $texts array to test hebrev() function $count = 1; $hebrew_text = "The hebrev function converts logical Hebrew text to visual text.\nThe function tries to avoid breaking words.\n"; foreach ($inputs as $max_chars_per_line) { echo "-- Iteration {$count} --\n"; var_dump(hebrev($hebrew_text, $max_chars_per_line)); $count++; } fclose($file_handle); //closing the file handle ?> ===DONE===
<?php /* Prototype : string hebrev ( string $hebrew_text [, int $max_chars_per_line ] ) * Description: Convert logical Hebrew text to visual text * Source code: ext/standard/string.c */ echo "*** Testing hebrev() : error conditions ***\n"; echo "\n-- Testing hebrev() function with no arguments --\n"; var_dump(hebrev()); echo "\n-- Testing hebrev() function with more than expected no. of arguments --\n"; $extra_arg = 10; var_dump(hebrev("Hello World", 5, $extra_arg)); ?> ===DONE===
/** * Draws text on the curren page. * * @param int $x X coordinate * @param int $y Y coordinate * @param int $font_size Font size * @param string $text The text to be drawn * @param int $alignment PdfDocument::AL_LEFT, PdfDocument::AL_CENTER or PdfDocument::AL_RIGHT * @return int Returns the height of the drawn text (to easily change the $y coordinate for the next call) */ public function drawText($x, $y, $font_size, $text, $alignment = self::AL_LEFT) { if (!$this->currentPage) { $this->currentPage = $this->createNewPage(); } $charEncoding = 'UTF-8'; $this->currentPage->setFont($this->Font, $font_size); $text = trim($text); $text = str_ireplace("\r\n", "\n", $text); $text = str_ireplace("<br/>", "\n", $text); $text = str_ireplace("<br>", "\n", $text); $text = str_ireplace("<br />", "\n", $text); $text = wordwrap($text, 110, "\n", false); switch ($alignment) { case self::AL_CENTER: $x = $x - $this->textWidth($text, $font_size) / 2; break; case self::AL_RIGHT: $x = $x - $this->textWidth($text, $font_size); break; } // spacial handling for multi-line texts if (strpos($text, "\n") !== false) { $rows = explode("\n", $text); foreach ($rows as $row) { $row = str_replace("\r", "", $row); $this->currentPage->drawText($row, $x, $y, $charEncoding); $y -= 12; } return $this->LineHeight * count($rows); } /** * Handle Arabic text (mantis #6712) */ if (0 < preg_match('/\\p{Arabic}/u', $text)) { system_load_module(__DIR__ . "/../../arabic.php"); $arglyphs = new I18N_Arabic('Glyphs'); $text = $arglyphs->utf8Glyphs($text); } else { if (0 < preg_match('/\\p{Hebrew}/u', $text)) { $text = iconv("ISO-8859-8", "UTF-8", hebrev(iconv("UTF-8", "ISO-8859-8//IGNORE", $text))); } } $this->currentPage->drawText($text, $x, $y, $charEncoding); return $this->LineHeight; }
function he($data) { return urlencode(strrev(hebrev(iconv("UTF-8", "ISO-8859-8", $data)))); }