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


PHP strcode2utf函数代码示例

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


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

示例1: barcode_c128

 /**
  * C128 barcodes. 
  * Very capable code, excellent density, high reliability; in very wide use world-wide
  */
 protected function barcode_c128($code, $type = 'B', $ean = false)
 {
     $code = strcode2utf($code);
     // mPDF 5.7.1	Allows e.g. <barcode code="5432&#013;1068" type="C128A" />
     $chr = array('212222', '222122', '222221', '121223', '121322', '131222', '122213', '122312', '132212', '221213', '221312', '231212', '112232', '122132', '122231', '113222', '123122', '123221', '223211', '221132', '221231', '213212', '223112', '312131', '311222', '321122', '321221', '312212', '322112', '322211', '212123', '212321', '232121', '111323', '131123', '131321', '112313', '132113', '132311', '211313', '231113', '231311', '112133', '112331', '132131', '113123', '113321', '133121', '313121', '211331', '231131', '213113', '213311', '213131', '311123', '311321', '331121', '312113', '312311', '332111', '314111', '221411', '431111', '111224', '111422', '121124', '121421', '141122', '141221', '112214', '112412', '122114', '122411', '142112', '142211', '241211', '221114', '413111', '241112', '134111', '111242', '121142', '121241', '114212', '124112', '124211', '411212', '421112', '421211', '212141', '214121', '412121', '111143', '111341', '131141', '114113', '114311', '411113', '411311', '113141', '114131', '311141', '411131', '211412', '211214', '211232', '233111', '200000');
     $keys = '';
     switch (strtoupper($type)) {
         case 'A':
             $startid = 103;
             $keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_';
             for ($i = 0; $i < 32; ++$i) {
                 $keys .= chr($i);
             }
             break;
         case 'B':
             $startid = 104;
             $keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~' . chr(127);
             break;
         case 'C':
             $startid = 105;
             $keys = '';
             if (strlen($code) % 2 != 0) {
                 // The length of barcode value must be even ($code). You must pad the number with zeros
                 return false;
             }
             for ($i = 0; $i <= 99; ++$i) {
                 $keys .= chr($i);
             }
             $new_code = '';
             $hclen = strlen($code) / 2;
             for ($i = 0; $i < $hclen; ++$i) {
                 $new_code .= chr(intval($code[2 * $i] . $code[2 * $i + 1]));
             }
             $code = $new_code;
             break;
         default:
             return false;
     }
     // calculate check character
     $sum = $startid;
     if ($ean) {
         $code = chr(102) . $code;
     }
     // Add FNC 1 - which identifies it as EAN-128
     $clen = strlen($code);
     for ($i = 0; $i < $clen; ++$i) {
         if ($ean && $i == 0) {
             $sum += 102;
         } else {
             $sum += strpos($keys, $code[$i]) * ($i + 1);
         }
     }
     $check = $sum % 103;
     $checkdigit = $check;
     // add start, check and stop codes
     $code = chr($startid) . $code . chr($check) . chr(106) . chr(107);
     $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
     $k = 0;
     $len = strlen($code);
     for ($i = 0; $i < $len; ++$i) {
         $ck = strpos($keys, $code[$i]);
         if ($i == 0 || ($ean && $i == 1) | $i > $len - 4) {
             $char_num = ord($code[$i]);
             $seq = $chr[$char_num];
         } elseif ($ck >= 0 and isset($chr[$ck])) {
             $seq = $chr[$ck];
         } else {
             // invalid character
             return false;
         }
         for ($j = 0; $j < 6; ++$j) {
             if ($j % 2 == 0) {
                 $t = true;
                 // bar
             } else {
                 $t = false;
                 // space
             }
             $w = $seq[$j];
             $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
             $bararray['maxw'] += $w;
             ++$k;
         }
     }
     $bararray['checkdigit'] = $checkdigit;
     return $bararray;
 }
开发者ID:ittiwat,项目名称:dpf_project,代码行数:91,代码来源:barcode.php

示例2: format_pdf

    /**
     * Pre-formats a PDF to the right size and, if not stated otherwise, with
     * header, footer and watermark (if any)
     * @param array $course_data General course information (to fill headers)
     * @param bool $complete Whether we want headers, footers and watermark or not
     */
    public function format_pdf($course_data, $complete = true)
    {
        if ($complete === false) {
            error_log('Asked with no decoration');
        }
        $course_code = null;
        if (!empty($course_data)) {
            $course_code = $course_data['code'];
        }

        /*$pdf->SetAuthor('Documents Chamilo');
        $pdf->SetTitle('title');
        $pdf->SetSubject('Exported from Chamilo Documents');
        $pdf->SetKeywords('Chamilo Documents');
        */
        // TODO: To be read from the html document.
        $this->pdf->directionality = api_get_text_direction();
        $this->pdf->useOnlyCoreFonts = true;
        // Use different Odd/Even headers and footers and mirror margins
        $this->pdf->mirrorMargins       = 1;

        // Add decoration only if not stated otherwise
        if ($complete) {
            // Adding watermark
            if (api_get_setting('pdf_export_watermark_enable') == 'true') {
                $watermark_file = self::get_watermark($course_code);

                if ($watermark_file) {
                    //http://mpdf1.com/manual/index.php?tid=269&searchstring=watermark
                    $this->pdf->SetWatermarkImage($watermark_file);
                    $this->pdf->showWatermarkImage = true;
                } else {
                    $watermark_file = self::get_watermark(null);
                    if ($watermark_file) {
                        $this->pdf->SetWatermarkImage($watermark_file);
                        $this->pdf->showWatermarkImage = true;
                    }
                }
                if ($course_code) {
                    $watermark_text = api_get_course_setting('pdf_export_watermark_text');
                    if (empty($watermark_text)) {
                        $watermark_text = api_get_setting('pdf_export_watermark_text');
                    }
                } else {
                    $watermark_text = api_get_setting('pdf_export_watermark_text');
                }
                if (!empty($watermark_text)) {
                    $this->pdf->SetWatermarkText(strcode2utf($watermark_text),0.1);
                    $this->pdf->showWatermarkText = true;
                }
            }

            if (empty($this->custom_header)) {
                self::set_header($course_data);
            } else {
                $this->pdf->SetHTMLHeader($this->custom_header,'E');
                $this->pdf->SetHTMLHeader($this->custom_header,'O');
            }

            if (empty($this->custom_footer)) {
                self::set_footer();
            } else {
                $this->pdf->SetHTMLFooter($this->custom_footer);
            }
        }
    }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:72,代码来源:pdf.lib.php

示例3: 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

示例4: get_arab_glyphs

function get_arab_glyphs($char, $type) {
	if ($type>0 && isset($this->arabGlyphs[$char])) {
		// If presentation form specified FB** - FE** = Arabic presentation Forms
		if (preg_match("/[\x{FB50}-\x{FEFF}]/u",$this->arabGlyphs[$char][$type])) {
			$unicode = $this->UTF8StringToArray($this->arabGlyphs[$char][$type], false);
			if ($this->_charDefined($this->CurrentFont['cw'],$unicode[0])) { return $this->arabGlyphs[$char][$type]; }
			else if (isset($this->CurrentFont['unAGlyphs'])) {
				$uni = $this->UTF8StringToArray($char, false);
				$pua = $uni[0] - 1536 + 62464 + 256*$type ;
				if ($this->_charDefined($this->CurrentFont['cw'], $pua)) { return strcode2utf('&#x' . dechex($pua) . ';'); }
				else return $char;
			}
			else return $char;
		}
		// If PUA form specified and unAGlphs font set F5** F6** F7** = Private use area used by unAGlyphs in mPDF
		if (preg_match("/[\x{F500}-\x{F7FF}]/u",$this->arabGlyphs[$char][$type]) && isset($this->CurrentFont['unAGlyphs'])) {
			$unicode = $this->UTF8StringToArray($this->arabGlyphs[$char][$type], false);
			if ($this->_charDefined($this->CurrentFont['cw'],$unicode[0])) { return $this->arabGlyphs[$char][$type]; }
			else return $char;
		}
		return $this->arabGlyphs[$char][$type]; 
	}
	else return $char;
}
开发者ID:joebotweb,项目名称:pdfcreator,代码行数:24,代码来源:mpdf.php

示例5: AutoFont

 function AutoFont($html)
 {
     if ($this->mpdf_ref->onlyCoreFonts) {
         return $html;
     }
     $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);
             $e = str_replace("&", "&amp;", $e);
             $e = str_replace("<", "&lt;", $e);
             $e = str_replace(">", "&gt;", $e);
             $a[$i] = $e;
             if (substr($a[$i - 1], 0, 5) != '<text' && substr($a[$i - 1], 0, 5) != '<tspa') {
                 continue;
             }
             $lang = '';
             // PASHTO, SINDHI, URDU, ARABIC, PERSIAN
             $persian = "\\x{067E}\\x{0686}\\x{0698}\\x{06AF}";
             $urdu = "\\x{0679}\\x{0688}\\x{0691}\\x{06BA}\\x{06BE}\\x{06C1}\\x{06D2}";
             $pashto = "\\x{067C}\\x{0681}\\x{0685}\\x{0689}\\x{0693}\\x{0696}\\x{069A}\\x{06BC}\\x{06D0}";
             $sindhi = "\\x{067A}\\x{067B}\\x{067D}\\x{067F}\\x{0680}\\x{0684}\\x{068D}\\x{068A}\\x{068F}\\x{068C}\\x{0687}\\x{0683}\\x{0699}\\x{06AA}\\x{06A6}\\x{06BB}\\x{06B1}\\x{06B3}";
             // CJK
             if (preg_match("/[" . $this->mpdf_ref->pregUHCchars . "]/u", $e)) {
                 $lang = 'ko';
             } else {
                 if (preg_match("/[" . $this->mpdf_ref->pregSJISchars . "]/u", $e)) {
                     $lang = 'ja';
                 } else {
                     if (preg_match("/[" . $this->mpdf_ref->pregCJKchars . "]/u", $e)) {
                         $lang = 'zh-CN';
                     } else {
                         if (preg_match("/[" . $this->mpdf_ref->pregHEBchars . "]/u", $e)) {
                             $lang = 'he';
                         } else {
                             if (preg_match("/[" . $sindhi . "]/u", $e)) {
                                 $lang = 'si';
                             } else {
                                 if (preg_match("/[" . $urdu . "]/u", $e)) {
                                     $lang = 'ur';
                                 } else {
                                     if (preg_match("/[" . $pashto . "]/u", $e)) {
                                         $lang = 'ps';
                                     } else {
                                         if (preg_match("/[" . $persian . "]/u", $e)) {
                                             $lang = 'fa';
                                         } else {
                                             if (preg_match("/[" . $this->mpdf_ref->pregARABICchars . "]/u", $e)) {
                                                 $lang = 'ar';
                                             } else {
                                                 if (preg_match("/[" . $this->mpdf_ref->pregBNchars . "]/u", $e)) {
                                                     $lang = 'bn';
                                                 } else {
                                                     if (preg_match("/[" . $this->mpdf_ref->pregHIchars . "]/u", $e)) {
                                                         $lang = 'hi';
                                                     } else {
                                                         if (preg_match("/[" . $this->mpdf_ref->pregGUchars . "]/u", $e)) {
                                                             $lang = 'gu';
                                                         } else {
                                                             if (preg_match("/[" . $this->mpdf_ref->pregMLchars . "]/u", $e)) {
                                                                 $lang = 'ml';
                                                             } else {
                                                                 if (preg_match("/[" . $this->mpdf_ref->pregKNchars . "]/u", $e)) {
                                                                     $lang = 'kn';
                                                                 } else {
                                                                     if (preg_match("/[" . $this->mpdf_ref->pregORchars . "]/u", $e)) {
                                                                         $lang = 'or';
                                                                     } else {
                                                                         if (preg_match("/[" . $this->mpdf_ref->pregPAchars . "]/u", $e)) {
                                                                             $lang = 'pa';
                                                                         } else {
                                                                             if (preg_match("/[" . $this->mpdf_ref->pregTAchars . "]/u", $e)) {
                                                                                 $lang = 'ta';
                                                                             } else {
                                                                                 if (preg_match("/[" . $this->mpdf_ref->pregTEchars . "]/u", $e)) {
                                                                                     $lang = 'te';
                                                                                 } else {
                                                                                     if (preg_match("/[\\x{0E00}-\\x{0E7F}]/u", $e)) {
                                                                                         $lang = 'th';
                                                                                     } else {
                                                                                         if (preg_match("/[" . $this->mpdf_ref->pregVIETchars . "]/u", $e)) {
                                                                                             $lang = 'vi';
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
//.........这里部分代码省略.........
开发者ID:quantumsized,项目名称:InvoicePlane,代码行数:101,代码来源:svg.php


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