当前位置: 首页>>代码示例>>PHP>>正文


PHP code2utf函数代码示例

本文整理汇总了PHP中code2utf函数的典型用法代码示例。如果您正苦于以下问题:PHP code2utf函数的具体用法?PHP code2utf怎么用?PHP code2utf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了code2utf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: js_unescape

/**
 * Function converts an Javascript escaped string back into a string with
 * specified charset (default is UTF-8).
 * Modified function from http://pure-essence.net/stuff/code/utf8RawUrlDecode.phps
 *
 * @param $source String escaped with Javascript's escape() function
 * @param $iconv_to String destination character set will be used as second parameter 
 * in the iconv function. Default is UTF-8.
 * @return string
 */
function js_unescape($source, $iconv_to = 'UTF-8')
{
    $decodedStr = '';
    $pos = 0;
    $len = strlen($source);
    while ($pos < $len) {
        $charAt = substr($source, $pos, 1);
        if ($charAt == '%') {
            $pos++;
            $charAt = substr($source, $pos, 1);
            if ($charAt == 'u') {
                // we got a unicode character
                $pos++;
                $unicodeHexVal = substr($source, $pos, 4);
                $unicode = hexdec($unicodeHexVal);
                $decodedStr .= code2utf($unicode);
                $pos += 4;
            } else {
                // we have an escaped ascii character
                $hexVal = substr($source, $pos, 2);
                $decodedStr .= chr(hexdec($hexVal));
                $pos += 2;
            }
        } else {
            $decodedStr .= $charAt;
            $pos++;
        }
    }
    if ($iconv_to != "UTF-8") {
        $decodedStr = iconv("UTF-8", $iconv_to, $decodedStr);
    }
    return $decodedStr;
}
开发者ID:amjadtbssm,项目名称:website,代码行数:43,代码来源:AjaxFunctions.php

示例2: unicode2UTF8

function unicode2UTF8($string)
{
    preg_match_all("/&#(.*?);/is", $string, $matches);
    if (count($matches[1])) {
        $unicode = $matches[1];
        for ($i = 0; $i < count($unicode); $i++) {
            $pattern[$i] = "/&#" . $unicode[$i] . ";/";
            $replace_str[$i] = iconv("UNICODE", "GB2312", code2utf($unicode[$i]));
        }
        return preg_replace($pattern, $replace_str, $string);
    } else {
        return $string;
    }
    return $string;
}
开发者ID:houweifeng,项目名称:sbase,代码行数:15,代码来源:functions.inc.php

示例3: codeHex2utf

 function codeHex2utf($hex, $lo = true)
 {
     $num = hexdec($hex);
     if ($num < 128 && !$lo) {
         return '&#x' . $hex . ';';
     }
     return code2utf($num, $lo);
 }
开发者ID:iamonuwa,项目名称:ivote,代码行数:8,代码来源:functions.php

示例4: _bidiReorder

 function _bidiReorder(&$chunkorder, &$content, &$cOTLdata, $blockdir)
 {
     $bidiData = array();
     // First combine into one array (and get the highest level in use)
     $numchunks = count($content);
     $maxlevel = 0;
     for ($nc = 0; $nc < $numchunks; $nc++) {
         $numchars = count($cOTLdata[$nc]['char_data']);
         for ($i = 0; $i < $numchars; ++$i) {
             $carac = array();
             if (isset($cOTLdata[$nc]['GPOSinfo'][$i])) {
                 $carac['GPOSinfo'] = $cOTLdata[$nc]['GPOSinfo'][$i];
             }
             $carac['uni'] = $cOTLdata[$nc]['char_data'][$i]['uni'];
             if (isset($cOTLdata[$nc]['char_data'][$i]['type'])) {
                 $carac['type'] = $cOTLdata[$nc]['char_data'][$i]['type'];
             }
             if (isset($cOTLdata[$nc]['char_data'][$i]['level'])) {
                 $carac['level'] = $cOTLdata[$nc]['char_data'][$i]['level'];
             }
             if (isset($cOTLdata[$nc]['char_data'][$i]['orig_type'])) {
                 $carac['orig_type'] = $cOTLdata[$nc]['char_data'][$i]['orig_type'];
             }
             $carac['group'] = $cOTLdata[$nc]['group'][$i];
             $carac['chunkid'] = $chunkorder[$nc];
             // gives font id and/or object ID
             $maxlevel = max(isset($carac['level']) ? $carac['level'] : 0, $maxlevel);
             $bidiData[] = $carac;
         }
     }
     if ($maxlevel == 0) {
         return;
     }
     $numchars = count($bidiData);
     // L1. On each line, reset the embedding level of the following characters to the paragraph embedding level:
     //	1. Segment separators (Tab) 'S',
     //	2. Paragraph separators 'B',
     //	3. Any sequence of whitespace characters 'WS' preceding a segment separator or paragraph separator, and
     //	4. Any sequence of whitespace characters 'WS' at the end of the line.
     //	The types of characters used here are the original types, not those modified by the previous phase cf N1 and N2*******
     //	Because a Paragraph Separator breaks lines, there will be at most one per line, at the end of that line.
     // Set the initial paragraph embedding level
     if ($blockdir == 'rtl') {
         $pel = 1;
     } else {
         $pel = 0;
     }
     for ($i = $numchars - 1; $i > 0; $i--) {
         if ($bidiData[$i]['type'] == UCDN::BIDI_CLASS_WS || isset($bidiData[$i]['orig_type']) && $bidiData[$i]['orig_type'] == UCDN::BIDI_CLASS_WS) {
             $bidiData[$i]['level'] = $pel;
         } else {
             break;
         }
     }
     // L2. From the highest level found in the text to the lowest odd level on each line, including intermediate levels not actually present in the text, reverse any contiguous sequence of characters that are at that level or higher.
     for ($j = $maxlevel; $j > 0; $j--) {
         $ordarray = array();
         $revarr = array();
         $onlevel = false;
         for ($i = 0; $i < $numchars; ++$i) {
             if ($bidiData[$i]['level'] >= $j) {
                 $onlevel = true;
                 // L4. A character is depicted by a mirrored glyph if and only if (a) the resolved directionality of that character is R, and (b) the Bidi_Mirrored property value of that character is true.
                 if (isset(UCDN::$mirror_pairs[$bidiData[$i]['uni']]) && $bidiData[$i]['type'] == UCDN::BIDI_CLASS_R) {
                     $bidiData[$i]['uni'] = UCDN::$mirror_pairs[$bidiData[$i]['uni']];
                 }
                 $revarr[] = $bidiData[$i];
             } else {
                 if ($onlevel) {
                     $revarr = array_reverse($revarr);
                     $ordarray = array_merge($ordarray, $revarr);
                     $revarr = array();
                     $onlevel = false;
                 }
                 $ordarray[] = $bidiData[$i];
             }
         }
         if ($onlevel) {
             $revarr = array_reverse($revarr);
             $ordarray = array_merge($ordarray, $revarr);
         }
         $bidiData = $ordarray;
     }
     $content = array();
     $cOTLdata = array();
     $chunkorder = array();
     $nc = -1;
     // New chunk order ID
     $chunkid = -1;
     foreach ($bidiData as $carac) {
         if ($carac['chunkid'] != $chunkid) {
             $nc++;
             $chunkorder[$nc] = $carac['chunkid'];
             $cctr = 0;
             $content[$nc] = '';
             $cOTLdata[$nc]['group'] = '';
         }
         if ($carac['uni'] != 0xfffc) {
             // Object replacement character (65532)
             $content[$nc] .= code2utf($carac['uni']);
//.........这里部分代码省略.........
开发者ID:prabhakarniraula,项目名称:Resume-Maker,代码行数:101,代码来源:otl.php

示例5: html_entity_decode_utf8

function html_entity_decode_utf8($string)
{
    static $trans_tbl;
    // replace numeric entities
    //php will have issues with numbers with leading zeros, so do not include them in what we send to code2utf.
    $string = preg_replace_callback('~&#x0*([0-9a-f]+);~i', function ($matches) {
        return code2utf(hexdec($matches[1]));
    }, $string);
    $string = preg_replace_callback('~&#0*([0-9]+);~', function ($matches) {
        return code2utf($matches[1]);
    }, $string);
    // replace literal entities
    if (!isset($trans_tbl)) {
        $trans_tbl = array();
        foreach (get_html_translation_table(HTML_ENTITIES) as $val => $key) {
            $trans_tbl[$key] = utf8_encode($val);
        }
    }
    return strtr($string, $trans_tbl);
}
开发者ID:recci,项目名称:SuiteCRM,代码行数:20,代码来源:utils.php

示例6: substituteIndic


//.........这里部分代码省略.........
                     while (preg_match('/(' . $tepartialforms . ') (E046|E069|E077)/', $vstr)) {
                         $vstr = preg_replace('/(' . $tepartialforms . ') (E046|E069|E077)/', '\\2 \\1', $vstr);
                     }
                     $vstr = preg_replace('/(' . $tefullforms . '|' . $matraligs . ') (E046|E069|E077)/', '\\2 \\1', $vstr);
                 } else {
                     if ($lang == 'kn') {
                         $knfullforms = "0C95|0C96|0C97|0C98|0C99|0C9A|0C9B|0C9C|0C9D|0C9E|0C9F|0CA0|0CA1|0CA2|0CA3|0CA4|0CA5|0CA6|0CA7|0CA8|0CAA|0CAB|0CAC|0CAD|0CAE|0CAF|0CB0|0CB1|0CB2|0CB3|0CB5|0CB6|0CB7|0CB8|0CB9|E07D|E07E|E0A3";
                         $knpartialforms = "E00C|E00D|E00E|E00F|E010|E011|E012|E013|E014|0C9E|E015|E016|E017|E018|E019|E01A|E01B|E01C|E01D|E01E|E01F|E020|E021|E022|E023|E024|E025|E026|E027|E028|E029|E02A|E02B|E02C|E02D|E07F";
                         while (preg_match('/E00B (' . $knpartialforms . ')/', $vstr)) {
                             $vstr = preg_replace('/E00B (' . $knpartialforms . ')/', '\\1 E00B', $vstr);
                         }
                         // mPDF 5.3.47  Also move Reph to right of matraIligatures
                         $knfullforms .= "|E082|E083|E084|E085|E086|E087|E088|E089|E08A|E08B|E08C|E08D|E08E|E08F|E090|E091|E092|E093|E094|E095|E096|E097|E098|E099|E09A|E09B|E09C|E09D|E09E|E09F|E0A0|E0A4|E0A1|E0A2";
                         $vstr = preg_replace('/E00B (' . $knfullforms . ')/', '\\1 E00B', $vstr);
                         // ? Need to shift it beyond base or below-base forms - haven't found so can't test??
                         // mPDF 5.3.87
                         // E004 added to list (which is a transformed version of 0CBE)
                         $knvowels = "0CBE|0CC0|0CC1|0CC2|0CC3|0CC4|0CC7|0CC8|0CCA|0CCB|0CD5|0CD6|E004";
                         $vstr = preg_replace('/E00B (' . $knvowels . ')/', '\\1 E00B', $vstr);
                     } else {
                         if ($lang == 'or') {
                             $orrephs = "E069|E06A|E06B|E06C";
                             $orfullforms = "0B15|0B16|0B17|0B18|0B19|0B1A|0B1B|0B1C|0B1D|0B1E|0B1F|0B20|0B21|0B22|0B23|0B24|0B25|0B26|0B27|0B28|0B29|0B2A|0B2B|0B2C|0B2D|0B2E|0B2F|0B30|0B31|0B32|0B33|0B34|0B35|0B36|0B37|0B38|E003|E004|E005|E006|E007|E008|E009|E00A|E00B|E00C|E00D|E00E|E00F|E010|E011|E012|E013|E014|E015|E016|E017|E018|E019|E01A|E01B|E01C|E01D|E01E|E01F|E020|E021|E022|E023|E024|E025|E026|E027|E028|E029|E02A|E02B|E02C|E02D|E02E|E02F|E030|E031|E032|E033|E034|E035|E036|E037";
                             // E123 - E147  FullHalant forms ? add to FullForms
                             $orpartialforms = "E090|E091|E092|E093|E094|E095|E096|E097|E098|E099|E09A|E09B|E09C|E09D|E09E|E09F|E0A0|E0A1|E0A2|E0A3|E0A4|E0A5|E0A6|E0A7|E0A8|E0A9|E0AA|E0AB|E0AC|E0AD|E0AE|E0AF|E0B0|E0B1|E0B2|E0B3|E0B4|E0B5|E0B6|E0B7|E0B8|E0B9|E0BA|E0BB|E0BC|E0BD|E0BE|E0BF|E0C0|E0C1|E0C2|E0C3|E0C4|E0C5|E0C6|E0C7|E0C8|E0C9|E0CA|E0CB|E0CC|E0CD|E0CE|E0CF|E0D0|E0D1|E0D2|E0D3|E0D4|E0D5|E0D6|E0D7|E0D8|E0D9|E0DA|E0DB|E0DC|E0DD|E0DE|E0DF|E0E0|E0E1|E0E2|E0E3|E0E4|E0E5|E0E6|E0E7|E0E8|E0E9|E0EA|E0EB|E0EC|E0ED|E0EE|E0EF|E0F0|E0F1|E0F2|E0F3|E0F4|E0F5";
                             // Combined MatraIReph[E06D] split [0B3F & E069] to allow reph to be shifted forwards
                             $vstr = preg_replace('/(' . $orfullforms . ') E06D (' . $orfullforms . ') 0B3E/', '\\1 0B3F E069 \\2 0B3E', $vstr);
                             while (preg_match('/(' . $orrephs . ') (' . $orpartialforms . ')/', $vstr)) {
                                 $vstr = preg_replace('/(' . $orrephs . ') (' . $orpartialforms . ')/', '\\2 \\1', $vstr);
                             }
                             $vstr = preg_replace('/(' . $orrephs . ') (' . $orfullforms . ')/', '\\2 \\1', $vstr);
                             // Combine Reph and MatraI
                             $vstr = str_replace('E069 0B3F', 'E06D', $vstr);
                             // Reph and MatraI -> MatraIReph
                             $vstr = str_replace('E06A 0B3F', 'E06E', $vstr);
                             // Reph and MatraI -> MatraIReph
                             $vstr = str_replace('E06B 0B3F', 'E06F', $vstr);
                             // Reph and MatraI -> MatraIReph
                         } else {
                             if ($lang == 'ml') {
                                 $halant = "0D4D";
                                 $vstr = preg_replace('/([A-F0-9]{4}) ' . $halant . ' 0D30/', 'E00E \\1', $vstr);
                                 // 0D30 = Ra
                                 $vstr = preg_replace('/([A-F0-9]{4}) ' . $halant . ' ' . $mlprebasedvowels . ' 0D30/', '\\2 E00E \\1', $vstr);
                                 // 0D30 = Ra
                                 $mlfullforms = "0D15|0D16|0D17|0D18|0D19|0D1A|0D1B|0D1C|0D1D|0D1E|0D1F|0D20|0D21|0D22|0D23|0D24|0D25|0D26|0D27|0D28|0D2A|0D2B|0D2C|0D2D|0D2E|0D2F|0D30|0D31|0D32|0D33|0D34|0D35|0D36|0D37|0D38|0D39" . "|E010|E011|E012|E013|E014|E015|E016|E017|E018|E019|E01A|E01B|E01C|E01D|E01E|E01F|E020|E021|E022|E023|E024|E025|E026|E027|E028|E029|E02A|E02B|E02C|E02D|E02E|E02F|E030|E031|E032|E033|E034|E035|E036|E037|E038|E039|E03A|E03B|E03C|E03D|E03E|E03F|E040|E041|E042|E043|E044|E045|E046|E047|E048|E049|E04A|E04B|E04C|E04D|E04E|E04F|E050|E051|E052|E053|E054|E055|E056|E057|E058|E059|E05A|E05B|E05C|E05D|E05E|E05F|E060|E061|E062|E063|E064|E065|E066|E067|E068|E069|E06A|E06B|E06C|E06D|E06E|E06F|E070|E071|E072|E073|E074|E075|E076|E077|E078|E079|E07A|E07B|E07C|E07D";
                                 // = FullConsonants + FullConjuncts
                                 // = Add Chillu characters	// mPDF 5.0.024
                                 $mlfullforms .= "|E004|E005|E006|E007|E008|E009";
                                 while (preg_match('/(' . $mlfullforms . ') E00E/', $vstr)) {
                                     $vstr = preg_replace('/(' . $mlfullforms . ') E00E/', 'E00E \\1', $vstr);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //============================
     // SHIFT post-based vowels to Left of SmallForms (NOT to left of full forms)
     // TELUGU Shift
     if ($lang == 'te') {
         // NB $tevowels defined above
         // NB $tefullforms defined above
         $tebelowbase1 = "E02C|E02D|E02E|E02F|E030|E031|E032|E033|E034|E035|E036|E037|E038|E039|E03A|E03B|E03C|E03D|E03E|E03F|E040|E041|E042|E043|E044|E045|E046|E047|E048|E049|E04A|E04B|E04C|E04D|E04E";
         //'Small1KaToHa'
         $tebelowbase2 = "E04F|E050|E051|E052|E053|E054|E055|E056|E057|E058|E059|E05A|E05B|E05C|E05D|E05E|E05F|E060|E061|E062|E063|E064|E065|E066|E067|E068|E069|E06A|E06B|E06C|E06D|E06E|E06F|E070|E071";
         // 'Small2KaToHa'
         $vstr = preg_replace('/(' . $tebelowbase2 . ') (' . $tevowels . ')/', '\\2 \\1', $vstr);
         $vstr = preg_replace('/(' . $tebelowbase1 . ') (' . $tevowels . ')/', '\\2 \\1', $vstr);
     } else {
         if ($lang == 'kn') {
             $knvowels = "0CBE|0CC0|0CC1|0CC2|0CC3|0CC4|0CC7|0CC8|0CCA|0CCB|0CD5|0CD6" . "|E004|E007|E008|E009|E00A";
             // NB $knvowels defined above
             // NB $fullforms defined above
             // $belowbase1/2 defined above
             $vstr = preg_replace('/(' . $belowbase2 . ') (' . $knvowels . ')/', '\\2 \\1', $vstr);
             // mPDF 5.3.87
             $vstr = preg_replace('/(' . $belowbase1 . ') (' . $knvowels . ')/', '\\2 \\1', $vstr);
             //$vstr = preg_replace('/('.$fullforms.') ('.$knvowels.')/', '\\2 \\1', $vstr);
         }
     }
     //============================
     // Clear unwanted ZWJ, ZWNJ
     // MALAYALAM
     if ($lang == 'ml') {
         $vstr = preg_replace('/(200C|200D) /', '', $vstr);
     }
     //============================
     // END & PUT IT BACK TOGETHER
     $vstr = preg_replace('/^0020 (.*) 0020$/', '\\1', $vstr);
     $varr = explode(" ", $vstr);
     $e = '';
     foreach ($varr as $v) {
         $e .= code2utf(hexdec($v));
     }
     //============================
     return $e;
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:101,代码来源:indic.php

示例7: dec2other

function dec2other($num, $cp) {
	$nstr = (string) $num;
	$rnum = '';
	for ($i=0;$i<strlen($nstr);$i++) { 
		if ($this->_charDefined($this->CurrentFont['cw'],$cp+intval($nstr[$i]))) { // contains arabic-indic numbers
			$rnum .= code2utf($cp+intval($nstr[$i]));
		}
		else { $rnum .= $nstr[$i]; }
	}
	return $rnum;
}
开发者ID:joebotweb,项目名称:pdfcreator,代码行数:11,代码来源:mpdf.php

示例8: unescape

function unescape($strIn, $iconv_to = 'UTF-8')
{
    $strOut = '';
    $iPos = 0;
    $len = strlen($strIn);
    while ($iPos < $len) {
        $charAt = substr($strIn, $iPos, 1);
        if ($charAt == '%') {
            $iPos++;
            $charAt = substr($strIn, $iPos, 1);
            if ($charAt == 'u') {
                // Unicode character
                $iPos++;
                $unicodeHexVal = substr($strIn, $iPos, 4);
                $unicode = hexdec($unicodeHexVal);
                $strOut .= code2utf($unicode);
                $iPos += 4;
            } else {
                // Escaped ascii character
                $hexVal = substr($strIn, $iPos, 2);
                if (hexdec($hexVal) > 127) {
                    // Convert to Unicode
                    $strOut .= code2utf(hexdec($hexVal));
                } else {
                    $strOut .= chr(hexdec($hexVal));
                }
                $iPos += 2;
            }
        } else {
            $strOut .= $charAt;
            $iPos++;
        }
    }
    if ($iconv_to != "UTF-8") {
        $strOut = iconv("UTF-8", $iconv_to, $strOut);
    }
    return $strOut;
}
开发者ID:SoftScape,项目名称:opensis,代码行数:38,代码来源:ajax.php

示例9: markScriptToLang

 function markScriptToLang($html)
 {
     if ($this->mpdf_ref->onlyCoreFonts) {
         return $html;
     }
     if (empty($this->script2lang)) {
         if (!empty($this->mpdf_ref->script2lang)) {
             $this->script2lang = $this->mpdf_ref->script2lang;
             $this->viet = $this->mpdf_ref->viet;
             $this->pashto = $this->mpdf_ref->pashto;
             $this->urdu = $this->mpdf_ref->urdu;
             $this->persian = $this->mpdf_ref->persian;
             $this->sindhi = $this->mpdf_ref->sindhi;
         } else {
             include _MPDF_PATH . 'config_script2lang.php';
         }
     }
     $n = '';
     $a = preg_split('/<(.*?)>/ms', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
     foreach ($a as $i => $e) {
         if ($i % 2 == 0) {
             $e = strcode2utf($e);
             $e = $this->mpdf_ref->lesser_entity_decode($e);
             $earr = $this->mpdf_ref->UTF8StringToArray($e, false);
             $scriptblock = 0;
             $scriptblocks = array();
             $scriptblocks[0] = 0;
             $chardata = array();
             $subchunk = 0;
             $charctr = 0;
             foreach ($earr as $char) {
                 $ucd_record = UCDN::get_ucd_record($char);
                 $sbl = $ucd_record[6];
                 if ($sbl && $sbl != 40 && $sbl != 102) {
                     if ($scriptblock == 0) {
                         $scriptblock = $sbl;
                         $scriptblocks[$subchunk] = $scriptblock;
                     } else {
                         if ($scriptblock > 0 && $scriptblock != $sbl) {
                             // NEW (non-common) Script encountered in this chunk.
                             // Start a new subchunk
                             $subchunk++;
                             $scriptblock = $sbl;
                             $charctr = 0;
                             $scriptblocks[$subchunk] = $scriptblock;
                         }
                     }
                 }
                 $chardata[$subchunk][$charctr]['script'] = $sbl;
                 $chardata[$subchunk][$charctr]['uni'] = $char;
                 $charctr++;
             }
             // If scriptblock[x] = common & non-baseScript
             // and scriptblock[x+1] = baseScript
             // Move common script from end of x to start of x+1
             for ($sch = 0; $sch < $subchunk; $sch++) {
                 if ($scriptblocks[$sch] > 0 && $scriptblocks[$sch] != $this->mpdf_ref->baseScript && $scriptblocks[$sch + 1] == $this->mpdf_ref->baseScript) {
                     $end = count($chardata[$sch]) - 1;
                     while ($chardata[$sch][$end]['script'] == 0 && $end > 1) {
                         // common script
                         $tmp = array_pop($chardata[$sch]);
                         array_unshift($chardata[$sch + 1], $tmp);
                         $end--;
                     }
                 }
             }
             $o = '';
             for ($sch = 0; $sch <= $subchunk; $sch++) {
                 if (isset($chardata[$sch])) {
                     $s = '';
                     for ($j = 0; $j < count($chardata[$sch]); $j++) {
                         $s .= code2utf($chardata[$sch][$j]['uni']);
                     }
                     // ZZZ99 Undo lesser_entity_decode as above - but only for <>&
                     $s = str_replace("&", "&amp;", $s);
                     $s = str_replace("<", "&lt;", $s);
                     $s = str_replace(">", "&gt;", $s);
                     if (substr($a[$i - 1], 0, 5) != '<text' && substr($a[$i - 1], 0, 5) != '<tspa') {
                         continue;
                     }
                     // <tspan> or <text> only
                     $lang = '';
                     // Check Vietnamese if Latin script - even if Basescript
                     if ($scriptblocks[$sch] == UCDN::SCRIPT_LATIN && $this->mpdf_ref->autoVietnamese && preg_match("/([" . $this->viet . "])/u", $s)) {
                         $lang = "vi";
                     } else {
                         if ($scriptblocks[$sch] == UCDN::SCRIPT_ARABIC && $this->mpdf_ref->autoArabic) {
                             if (preg_match("/[" . $this->sindhi . "]/u", $s)) {
                                 $lang = "sd";
                             } else {
                                 if (preg_match("/[" . $this->urdu . "]/u", $s)) {
                                     $lang = "ur";
                                 } else {
                                     if (preg_match("/[" . $this->pashto . "]/u", $s)) {
                                         $lang = "ps";
                                     } else {
                                         if (preg_match("/[" . $this->persian . "]/u", $s)) {
                                             $lang = "fa";
                                         } else {
                                             if ($this->mpdf_ref->baseScript != UCDN::SCRIPT_ARABIC && isset($this->script2lang[$scriptblocks[$sch]])) {
//.........这里部分代码省略.........
开发者ID:hipogea,项目名称:zega,代码行数:101,代码来源:svg.php

示例10: _bidiSort


//.........这里部分代码省略.........
             if ($left && $left == $right) {
                 $chardata[$i]['type'] = $left;
             }
         }
     }
     // N2. Any remaining neutrals take the embedding direction
     for ($i = 0; $i < $numchars; ++$i) {
         if ($chardata[$i]['type'] == 'ON' || $chardata[$i]['type'] == 'WS') {
             $chardata[$i]['type'] = $chardata[$i]['level'] % 2 ? 'R' : 'L';
         }
     }
     // I1. For all characters with an even (left-to-right) embedding direction, those of type R go up one level and those of type AN or EN go up two levels.
     // I2. For all characters with an odd (right-to-left) embedding direction, those of type L, EN or AN go up one level.
     for ($i = 0; $i < $numchars; ++$i) {
         $odd = $chardata[$i]['level'] % 2;
         if ($odd) {
             if ($chardata[$i]['type'] == 'L' || $chardata[$i]['type'] == 'AN' || $chardata[$i]['type'] == 'EN') {
                 $chardata[$i]['level'] += 1;
             }
         } else {
             if ($chardata[$i]['type'] == 'R') {
                 $chardata[$i]['level'] += 1;
             } else {
                 if ($chardata[$i]['type'] == 'AN' || $chardata[$i]['type'] == 'EN') {
                     $chardata[$i]['level'] += 2;
                 }
             }
         }
         $maxlevel = max($chardata[$i]['level'], $maxlevel);
     }
     // L1. On each line, reset the embedding level of the following characters to the paragraph embedding level:
     //	1. Segment separators,
     //	2. Paragraph separators,
     //	3. Any sequence of whitespace characters preceding a segment separator or paragraph separator, and
     //	4. Any sequence of whitespace characters at the end of the line.
     for ($i = $numchars - 1; $i > 0; $i--) {
         if ($chardata[$i]['type'] == 'WS') {
             $chardata[$i]['level'] = $pel;
         } else {
             break;
         }
     }
     // L2. From the highest level found in the text to the lowest odd level on each line, including intermediate levels not actually present in the text, reverse any contiguous sequence of characters that are at that level or higher.
     for ($j = $maxlevel; $j > 0; $j--) {
         $ordarray = array();
         $revarr = array();
         $onlevel = false;
         for ($i = 0; $i < $numchars; ++$i) {
             if ($chardata[$i]['level'] >= $j) {
                 $onlevel = true;
                 // L4. A character is depicted by a mirrored glyph if and only if (a) the resolved directionality of that character is R, and (b) the Bidi_Mirrored property value of that character is true.
                 if (isset(UCDN::$mirror_pairs[$chardata[$i]['char']]) && $chardata[$i]['type'] == 'R') {
                     $chardata[$i]['char'] = UCDN::$mirror_pairs[$chardata[$i]['char']];
                 }
                 $revarr[] = $chardata[$i];
             } else {
                 if ($onlevel) {
                     $revarr = array_reverse($revarr);
                     $ordarray = array_merge($ordarray, $revarr);
                     $revarr = array();
                     $onlevel = false;
                 }
                 $ordarray[] = $chardata[$i];
             }
         }
         if ($onlevel) {
             $revarr = array_reverse($revarr);
             $ordarray = array_merge($ordarray, $revarr);
         }
         $chardata = $ordarray;
     }
     $group = '';
     $e = '';
     $GPOS = array();
     $cctr = 0;
     $rtl_content = 0x0;
     foreach ($chardata as $cd) {
         $e .= code2utf($cd['char']);
         $group .= $cd['group'];
         if ($useGPOS && is_array($cd['GPOSinfo'])) {
             $GPOS[$cctr] = $cd['GPOSinfo'];
             $GPOS[$cctr]['wDir'] = $cd['level'] % 2 ? 'RTL' : 'LTR';
         }
         if ($cd['type'] == 'L') {
             $rtl_content |= 1;
         } else {
             if ($cd['type'] == 'R') {
                 $rtl_content |= 2;
             }
         }
         $cctr++;
     }
     $chunkOTLdata['group'] = $group;
     if ($useGPOS) {
         $chunkOTLdata['GPOSinfo'] = $GPOS;
     }
     // NB Don't reverse chunkOTLdata['bidi_type'] - req'd in WriteFlowing Block for $lastBidiType in original logical order
     // NB Does reverse chunkOTLdata['group']
     return array($e, $rtl_content);
 }
开发者ID:Lexinek,项目名称:mpdf-replace,代码行数:101,代码来源:otl.php

示例11: __chr2utf

 /**
  * Converts char code to UTF codepoing, if required
  *
  * @param $chr char or 4-byte hex
  * @return string UTF codepoint
  */
 function __chr2utf($chr)
 {
     if (preg_match("/^[\\da-f]{4,6}\$/i", $chr)) {
         return code2utf(hexdec($chr));
     } else {
         return $chr;
     }
 }
开发者ID:bqq1986,项目名称:efront,代码行数:14,代码来源:vk.inc.php

示例12: substituteIndic


//.........这里部分代码省略.........
                         while (preg_match('/E00B (' . $knpartialforms . ')/', $vstr)) {
                             $vstr = preg_replace('/E00B (' . $knpartialforms . ')/', '\\1 E00B', $vstr);
                         }
                         // mPDF 5.3.47  Also move Reph to right of matraIligatures
                         $knfullforms .= "|E082|E083|E084|E085|E086|E087|E088|E089|E08A|E08B|E08C|E08D|E08E|E08F|E090|E091|E092|E093|E094|E095|E096|E097|E098|E099|E09A|E09B|E09C|E09D|E09E|E09F|E0A0|E0A4|E0A1|E0A2";
                         $vstr = preg_replace('/E00B (' . $knfullforms . ')/', '\\1 E00B', $vstr);
                         // ? Need to shift it beyond base or below-base forms - haven't found so can't test??
                         // mPDF 5.3.87
                         // E004 added to list (which is a transformed version of 0CBE)
                         $knvowels = "0CBE|0CC0|0CC1|0CC2|0CC3|0CC4|0CC7|0CC8|0CCA|0CCB|0CD5|0CD6|E004";
                         $vstr = preg_replace('/E00B (' . $knvowels . ')/', '\\1 E00B', $vstr);
                     } else {
                         if ($lang == 'or') {
                             $orrephs = "E069|E06A|E06B|E06C";
                             $orfullforms = "0B15|0B16|0B17|0B18|0B19|0B1A|0B1B|0B1C|0B1D|0B1E|0B1F|0B20|0B21|0B22|0B23|0B24|0B25|0B26|0B27|0B28|0B29|0B2A|0B2B|0B2C|0B2D|0B2E|0B2F|0B30|0B31|0B32|0B33|0B34|0B35|0B36|0B37|0B38|E003|E004|E005|E006|E007|E008|E009|E00A|E00B|E00C|E00D|E00E|E00F|E010|E011|E012|E013|E014|E015|E016|E017|E018|E019|E01A|E01B|E01C|E01D|E01E|E01F|E020|E021|E022|E023|E024|E025|E026|E027|E028|E029|E02A|E02B|E02C|E02D|E02E|E02F|E030|E031|E032|E033|E034|E035|E036|E037";
                             // E123 - E147  FullHalant forms ? add to FullForms
                             $orpartialforms = "E090|E091|E092|E093|E094|E095|E096|E097|E098|E099|E09A|E09B|E09C|E09D|E09E|E09F|E0A0|E0A1|E0A2|E0A3|E0A4|E0A5|E0A6|E0A7|E0A8|E0A9|E0AA|E0AB|E0AC|E0AD|E0AE|E0AF|E0B0|E0B1|E0B2|E0B3|E0B4|E0B5|E0B6|E0B7|E0B8|E0B9|E0BA|E0BB|E0BC|E0BD|E0BE|E0BF|E0C0|E0C1|E0C2|E0C3|E0C4|E0C5|E0C6|E0C7|E0C8|E0C9|E0CA|E0CB|E0CC|E0CD|E0CE|E0CF|E0D0|E0D1|E0D2|E0D3|E0D4|E0D5|E0D6|E0D7|E0D8|E0D9|E0DA|E0DB|E0DC|E0DD|E0DE|E0DF|E0E0|E0E1|E0E2|E0E3|E0E4|E0E5|E0E6|E0E7|E0E8|E0E9|E0EA|E0EB|E0EC|E0ED|E0EE|E0EF|E0F0|E0F1|E0F2|E0F3|E0F4|E0F5";
                             // Combined MatraIReph[E06D] split [0B3F & E069] to allow reph to be shifted forwards
                             $vstr = preg_replace('/(' . $orfullforms . ') E06D (' . $orfullforms . ') 0B3E/', '\\1 0B3F E069 \\2 0B3E', $vstr);
                             while (preg_match('/(' . $orrephs . ') (' . $orpartialforms . ')/', $vstr)) {
                                 $vstr = preg_replace('/(' . $orrephs . ') (' . $orpartialforms . ')/', '\\2 \\1', $vstr);
                             }
                             $vstr = preg_replace('/(' . $orrephs . ') (' . $orfullforms . ')/', '\\2 \\1', $vstr);
                             // Combine Reph and MatraI
                             $vstr = str_replace('E069 0B3F', 'E06D', $vstr);
                             // Reph and MatraI -> MatraIReph
                             $vstr = str_replace('E06A 0B3F', 'E06E', $vstr);
                             // Reph and MatraI -> MatraIReph
                             $vstr = str_replace('E06B 0B3F', 'E06F', $vstr);
                             // Reph and MatraI -> MatraIReph
                         } else {
                             if ($lang == 'ml') {
                                 $halant = "0D4D";
                                 $vstr = preg_replace('/([A-F0-9]{4}) ' . $halant . ' 0D30/', 'E00E \\1', $vstr);
                                 // 0D30 = Ra
                                 $vstr = preg_replace('/([A-F0-9]{4}) ' . $halant . ' ' . $mlprebasedvowels . ' 0D30/', '\\2 E00E \\1', $vstr);
                                 // 0D30 = Ra
                                 $mlfullforms = "0D15|0D16|0D17|0D18|0D19|0D1A|0D1B|0D1C|0D1D|0D1E|0D1F|0D20|0D21|0D22|0D23|0D24|0D25|0D26|0D27|0D28|0D2A|0D2B|0D2C|0D2D|0D2E|0D2F|0D30|0D31|0D32|0D33|0D34|0D35|0D36|0D37|0D38|0D39" . "|E010|E011|E012|E013|E014|E015|E016|E017|E018|E019|E01A|E01B|E01C|E01D|E01E|E01F|E020|E021|E022|E023|E024|E025|E026|E027|E028|E029|E02A|E02B|E02C|E02D|E02E|E02F|E030|E031|E032|E033|E034|E035|E036|E037|E038|E039|E03A|E03B|E03C|E03D|E03E|E03F|E040|E041|E042|E043|E044|E045|E046|E047|E048|E049|E04A|E04B|E04C|E04D|E04E|E04F|E050|E051|E052|E053|E054|E055|E056|E057|E058|E059|E05A|E05B|E05C|E05D|E05E|E05F|E060|E061|E062|E063|E064|E065|E066|E067|E068|E069|E06A|E06B|E06C|E06D|E06E|E06F|E070|E071|E072|E073|E074|E075|E076|E077|E078|E079|E07A|E07B|E07C|E07D";
                                 // = FullConsonants + FullConjuncts
                                 // = Add Chillu characters	// mPDF 5.0.024
                                 $mlfullforms .= "|E004|E005|E006|E007|E008|E009";
                                 while (preg_match('/(' . $mlfullforms . ') E00E/', $vstr)) {
                                     $vstr = preg_replace('/(' . $mlfullforms . ') E00E/', 'E00E \\1', $vstr);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //============================
     // SHIFT post-based vowels to Left of SmallForms (NOT to left of full forms)
     // TELUGU Shift
     if ($lang == 'te') {
         // NB $tevowels defined above
         // NB $tefullforms defined above
         $tebelowbase1 = "E02C|E02D|E02E|E02F|E030|E031|E032|E033|E034|E035|E036|E037|E038|E039|E03A|E03B|E03C|E03D|E03E|E03F|E040|E041|E042|E043|E044|E045|E046|E047|E048|E049|E04A|E04B|E04C|E04D|E04E";
         //'Small1KaToHa'
         $tebelowbase2 = "E04F|E050|E051|E052|E053|E054|E055|E056|E057|E058|E059|E05A|E05B|E05C|E05D|E05E|E05F|E060|E061|E062|E063|E064|E065|E066|E067|E068|E069|E06A|E06B|E06C|E06D|E06E|E06F|E070|E071";
         // 'Small2KaToHa'
         $vstr = preg_replace('/(' . $tebelowbase2 . ') (' . $tevowels . ')/', '\\2 \\1', $vstr);
         $vstr = preg_replace('/(' . $tebelowbase1 . ') (' . $tevowels . ')/', '\\2 \\1', $vstr);
     } else {
         if ($lang == 'kn') {
             $knvowels = "0CBE|0CC0|0CC1|0CC2|0CC3|0CC4|0CC7|0CC8|0CCA|0CCB|0CD5|0CD6" . "|E004|E007|E008|E009|E00A";
             // NB $knvowels defined above
             // NB $fullforms defined above
             // $belowbase1/2 defined above
             $vstr = preg_replace('/(' . $belowbase2 . ') (' . $knvowels . ')/', '\\2 \\1', $vstr);
             // mPDF 5.3.87
             $vstr = preg_replace('/(' . $belowbase1 . ') (' . $knvowels . ')/', '\\2 \\1', $vstr);
             //$vstr = preg_replace('/('.$fullforms.') ('.$knvowels.')/', '\\2 \\1', $vstr);
         }
     }
     //============================
     // Clear unwanted ZWJ, ZWNJ
     // MALAYALAM
     if ($lang == 'ml') {
         $vstr = preg_replace('/(200C|200D) /', '', $vstr);
     }
     //============================
     // END & PUT IT BACK TOGETHER
     $vstr = preg_replace('/^0020 (.*) 0020$/', '\\1', $vstr);
     $varr = explode(" ", $vstr);
     $e = '';
     //	foreach($varr AS $v) {
     //		$e.=code2utf(hexdec($v));
     //	}
     // E00 SERIES REPLACED BY 040 AND E01 SERIES REPLACED BY 041
     $array = array('E001' => 'F5B5', 'E002' => 'F5B6', 'E003' => 'F5B7', 'E004' => 'F5AD', 'E005' => 'F5AE', 'E006' => 'F5AF', 'E007' => 'F5B0', 'E008' => 'F5B1', 'E009' => '0915', 'E00A' => '092A', 'E00B' => '040B', 'E00C' => '040C', 'E00D' => '040D', 'E00E' => '040E', 'E00F' => '040F', 'E010' => 'F307', 'E011' => '0411', 'E012' => '0412', 'E013' => 'F1B0', 'E014' => 'F306', 'E015' => 'F306', 'E016' => '0416', 'E017' => '0417', 'E026' => 'F121', 'E027' => 'F123', 'E028' => 'F337', 'E029' => 'F338', 'E043' => 'F33A', 'E044' => 'F33B', 'E045' => 'F33C', 'E046' => 'F33D', 'E048' => 'F33E', 'E049' => '091B 094D', 'E04A' => 'F33F', 'E04B' => 'F340', 'E04C' => 'F343', 'E051' => 'F344', 'E052' => 'F346', 'E053' => 'F347', 'E054' => '0926 O04D', 'E055' => 'F348', 'E056' => 'F34A', 'E057' => 'F34B', 'E058' => 'F34C', 'E059' => 'F34D', 'E05A' => 'F34E', 'E05B' => 'F350', 'E05C' => 'F351', 'E05D' => 'F352', 'E05E' => 'F353', 'E05F' => 'F355', 'E060' => 'F356', 'E061' => 'F357', 'E062' => 'F35A', 'E063' => 'F35B', 'E064' => 'F35C', 'E065' => 'F35D', 'E066' => 'F35F', 'E08B' => 'F363', 'E08C' => 'F364', 'E08D' => 'F365', 'E08E' => 'F366', 'E08F' => '0919 094D 0930', 'E090' => 'F367', 'E091' => '091B 094D 0930', 'E092' => 'F368', 'E093' => 'F369', 'E094' => 'F36B', 'E095' => '091F 094D 0930', 'E096' => '0920 094D 0930', 'E097' => '0921 094D 0930', 'E098' => '0922 094D 0930', 'E099' => 'F36C', 'E09A' => 'F36E', 'E09B' => 'F36F', 'E09C' => 'F370', 'E09D' => 'F371', 'E09E' => 'F373', 'E09F' => 'F374', 'E0A0' => 'F375', 'E0A1' => 'F376', 'E0A2' => 'F377', 'E0A3' => 'F379', 'E0A4' => 'F37A', 'E0A5' => '', 'E0A6' => 'F37B', 'E0A7' => '', 'E0A8' => 'F37C', 'E0A9' => 'F37D', 'E0AA' => 'F37E', 'E0AB' => 'F37F', 'E0AC' => 'F380', 'E0AD' => 'F382', 'E0AE' => 'F383', 'E0D3' => 'F386', 'E0D4' => 'F387', 'E0D5' => 'F388', 'E0D6' => 'F389', 'E0D8' => 'F38A', 'E0DA' => 'F38B', 'E0DB' => 'F38C', 'EODC' => 'F38E', 'EOE1' => 'F38F', 'E0E2' => 'F391', 'EOE3' => 'F392', 'E0E5' => 'F393', 'E0E6' => 'F395', 'E0E7' => 'F396', 'E0E8' => 'F397', 'E0E9' => 'F398', 'E0EA' => 'F399', 'EOEB' => 'F39B', 'EOEC' => 'F39C', 'E0EE' => 'F39D', 'E0F0' => 'F39E', 'E0F1' => 'F39F', 'E0F2' => 'F3A0', 'EOF3' => 'F3A1', 'E0F4' => 'F3A2', 'E0F5' => 'F3A4', 'E0F6' => 'F3A7', 'E11B' => 'F3FF', 'E11C' => 'F413', 'E11D' => 'F59F F68A', 'E11E' => 'F444', 'E11F' => 'F449', 'E120' => 'F44F', 'E121' => 'F469', 'E122' => 'F45A', 'E123' => 'F46A', 'E124' => 'F477', 'E125' => 'F47C', 'E126' => 'F480', 'E127' => 'F482', 'E128' => 'F48E', 'E129' => 'F493', 'E12A' => 'F4B1', 'E12B' => 'F4E0', 'E12C' => 'F4DD', 'E12D' => 'F4E2', 'E12E' => 'F4E5', 'E12F' => 'F4E7', 'E130' => 'F4E8', 'E16D' => 'F55E', '091C 094D 091C' => 'F459', 'E14B' => 'F30D', 'E14C' => 'F311', 'E14D' => 'F314', 'E14E' => 'F318', 'E131' => 'F4E7', 'E194' => 'F325', 'E195' => 'F326', 'E196' => 'F327', 'E198' => 'F328', 'E133' => 'F4F4', 'E134' => 'F4F8', 'E135' => 'F4FB', 'E136' => 'F4FD', 'E137' => 'F4F6', 'E138' => 'F500', 'E139' => 'F504', 'E13B' => 'F413', 'E13D' => 'F3F3', 'E140' => 'F533', 'E141' => 'F544', 'E142' => 'F543', 'E143' => 'F545', 'E145' => 'F548', 'E153' => 'F556', 'E154' => 'F557', 'E11D' => 'F59F F68A');
     foreach ($varr as $v) {
         if ($font == 'ind_hi_2_001' && isset($array[$v])) {
             $v = $array[$v];
         }
         $e .= code2utf(hexdec($v));
     }
     //============================
     return $e;
 }
开发者ID:BlueBream,项目名称:AKA,代码行数:101,代码来源:indic.php

示例13: codeHex2utf

  function codeHex2utf($hex,$lo=true){
	$num = hexdec($hex);
	if (($num<128) && !$lo) return '&#x'.$hex.';';	// i.e. no change
	return code2utf($num,$lo);
  }
开发者ID:khushbu-soni,项目名称:server,代码行数:5,代码来源:functions.php

示例14: html_entity_decode_utf8

function html_entity_decode_utf8($string, $htmltrans = false)
{
    static $trans_tbl;
    if (!isset($trans_tbl)) {
        $trans_tbl = array();
        foreach (get_html_translation_table(HTML_ENTITIES) as $val => $key) {
            $trans_tbl[$key] = utf8_encode($val);
        }
    }
    $string = preg_replace_callback(array('~&#x([0-9a-f]+);~i', '~%u([0-9a-f]{4})~i'), function ($matches) {
        return code2utf(hexdec($matches[1]));
    }, $string);
    $string = preg_replace_callback('~&#([0-9]+);~', function ($matches) {
        return code2utf($matches[1]);
    }, $string);
    if ($htmltrans) {
        $string = strtr($string, $trans_tbl);
    }
    return $string;
}
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:20,代码来源:utils.php

示例15: decode_jsescape

function decode_jsescape($string)
{
    preg_match_all('/%u[0-9A-F]{4}/', $string, $u_codes);
    foreach ($u_codes[0] as $code) {
        $string = str_replace($code, code2utf(hexdec(substr($code, 2, 4))), $string);
    }
    return $string;
}
开发者ID:dalinhuang,项目名称:shopexts,代码行数:8,代码来源:func_ext.php


注:本文中的code2utf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。