當前位置: 首頁>>代碼示例>>PHP>>正文


PHP mb_encode_numericentity函數代碼示例

本文整理匯總了PHP中mb_encode_numericentity函數的典型用法代碼示例。如果您正苦於以下問題:PHP mb_encode_numericentity函數的具體用法?PHP mb_encode_numericentity怎麽用?PHP mb_encode_numericentity使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了mb_encode_numericentity函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: encodeEntities

 public static function encodeEntities($str, $encoding = 'UTF-8', $convmap = null)
 {
     if ($convmap && function_exists('mb_encode_numericentity')) {
         return mb_encode_numericentity($str, $convmap, $encoding);
     }
     return htmlentities($str, ENT_QUOTES, $encoding);
 }
開發者ID:Sywooch,項目名稱:forums,代碼行數:7,代碼來源:AJAXChatEncoding.php

示例2: escape

 public static function escape($string, $encoding = null)
 {
     if (empty($string)) {
         return $string;
     }
     if (Kint::$enabled_mode === Kint::MODE_CLI) {
         return str_replace("", '\\x1b', $string);
     }
     if (Kint::$enabled_mode === Kint::MODE_WHITESPACE) {
         return $string;
     }
     if ($encoding === null) {
         $encoding = self::detectEncoding($string);
     }
     $string = htmlspecialchars($string, ENT_NOQUOTES, $encoding === 'ASCII' ? 'UTF-8' : $encoding);
     if ($encoding === 'UTF-8') {
         // TODO: we could make the symbols hover-title show the code for the invisible symbol
         // when possible force invisible characters to have some sort of display (experimental)
         $string = preg_replace('/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\x80-\\x9F]/u', '?', $string);
     }
     // this call converts all non-ASCII characters into html chars of format
     if (function_exists('mb_encode_numericentity')) {
         $string = mb_encode_numericentity($string, array(0x80, 0xffff, 0, 0xffff), $encoding);
     }
     return $string;
 }
開發者ID:jnvsor,項目名稱:kint,代碼行數:26,代碼來源:Blob.php

示例3: courierimage

function courierimage($char, $width = 8, $height = 12, $pdir = 'patterns/')
{
    $im = imagecreate($width, $height);
    $background_color = imagecolorallocate($im, 255, 255, 255);
    $text_color = imagecolorallocate($im, 0, 0, 0);
    $imchar = $char;
    $imchar = mb_encode_numericentity($imchar, array(0x0, 0xffff, 0, 0xffff), 'UTF-8');
    // echo $imchar;
    imagettftext($im, 10, 0, 0, 10, $text_color, 'cour.ttf', $imchar);
    $imgarray_0 = img2array($im, $width, $height);
    $imgarray_1 = img_array_split($imgarray_0);
    $imgarray_2 = img_array_split($imgarray_1);
    $ia2name = img_array_name($imgarray_2);
    if (!file_exists($pdir . $ia2name)) {
        mkdir($pdir . $ia2name);
    }
    $ia1name = img_array_name($imgarray_1);
    if (!file_exists($pdir . $ia2name . '/' . $ia1name)) {
        mkdir($pdir . $ia2name . '/' . $ia1name);
    }
    $ia0name = img_array_name($imgarray_0);
    $filename = $pdir . $ia2name . '/' . $ia1name . '/' . $ia0name . '.txt';
    if (!file_exists($filename)) {
        writeUTF8File($filename, $char);
    }
    $filename = $pdir . $ia2name . '/' . $ia1name . '/' . $ia0name . '.gif';
    if (!file_exists($filename)) {
        ImageGif($im, $filename);
        chmod($filename, 0777);
    }
    // echo '<table><tr><td>'.print_img_array($imgarray_0).'</td><td>'.print_img_array($imgarray_1).'</td><td>'.print_img_array($imgarray_2)."</td><td><img src=\"$filename\" /></td></table>";
}
開發者ID:andrewsalveson,項目名稱:asciirender,代碼行數:32,代碼來源:unicoderender.php

示例4: kfJsonEncode

/**
 * Polyfill for json_encode JSON_UNESCAPED_UNICODE (new in PHP 5.4.0) for PHP 5.3
 */
function kfJsonEncode($arr)
{
    array_walk_recursive($arr, function (&$item, $key) {
        if (is_string($item)) {
            $item = mb_encode_numericentity($item, array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
        }
    });
    return mb_decode_numericentity(json_encode($arr), array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
}
開發者ID:JeanFred,項目名稱:intuition,代碼行數:12,代碼來源:wpAvailableLanguages.js.php

示例5: _convertUtf8ToSjis

 /**
  * Convert character encoding from UTF-8 to Shift_JIS.
  *
  * @param  string  $text
  * @return string
  */
 function _convertUtf8ToSjis($text)
 {
     $text = mb_encode_numericentity($text, $this->_utf8map, 'UTF-8');
     $text = mb_convert_encoding($text, 'SJIS-win', 'UTF-8');
     $pattern = '/&#(6\\d{4});/';
     $callback = array($this, '_convertDecimalToSjis');
     $text = preg_replace_callback($pattern, $callback, $text);
     return $text;
 }
開發者ID:k1LoW,項目名稱:yak,代碼行數:15,代碼來源:Aumail.php

示例6: escapeXML

 public static function escapeXML($string)
 {
     $string = preg_replace('/&/is', '&amp;', $string);
     $string = preg_replace('/</is', '&lt;', $string);
     $string = preg_replace('/>/is', '&gt;', $string);
     $string = preg_replace('/\'/is', '&#39;', $string);
     $string = preg_replace('/"/is', '&quot;', $string);
     $string = str_replace(array('ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż', 'Ą', 'Ć', 'Ę', 'Ł', 'Ń', 'Ó', 'Ś', 'Ź', 'Ż', 'ü', 'ò', 'è', 'à', 'ì'), array('a', 'c', 'e', 'l', 'n', 'o', 's', 'z', 'z', 'A', 'C', 'E', 'L', 'N', 'O', 'S', 'Z', 'Z', 'u', 'o', 'e', 'a', 'i'), $string);
     return mb_encode_numericentity(trim($string), array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
 }
開發者ID:AleksNesh,項目名稱:pandora,代碼行數:10,代碼來源:Help.php

示例7: json_encode_readable

function json_encode_readable($arr)
{
    //convmap since 0x80 char codes so it takes all multibyte codes (above ASCII 127). So such characters are being "hidden" from normal json_encoding
    array_walk_recursive($arr, function (&$item, $key) {
        if (is_string($item)) {
            $item = mb_encode_numericentity($item, array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
        }
    });
    return mb_decode_numericentity(json_encode($arr), array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
}
開發者ID:ayunah,項目名稱:opencorpora,代碼行數:10,代碼來源:api.php

示例8: _convertUtf8ToEntity

 /**
  * Callback function called by the filter() method.
  *
  * This function converts UTF-8 emoji to hexadecimal character reference.
  *
  * @param  array   $matches
  * @return string
  */
 function _convertUtf8ToEntity($matches)
 {
     $utf8 = $matches[0];
     $entity = mb_encode_numericentity($utf8, $this->_convmap, 'UTF-8');
     if ($utf8 !== $entity) {
         $unicode = (int) substr($entity, 2, 5);
         return '&#x' . dechex($unicode) . ';';
     } else {
         return $utf8;
     }
 }
開發者ID:k1LoW,項目名稱:yak,代碼行數:19,代碼來源:Utf8ToHex.php

示例9: make_confusing

 public static function make_confusing($string)
 {
     $chars = str_split($string);
     foreach ($chars as &$c) {
         if (rand(0, 2) != 0) {
             continue;
         }
         $c = mb_encode_numericentity($c, array(0, 0xffff, 0, 0xffff), 'UTF-8');
     }
     return implode('', $chars);
 }
開發者ID:niksfish,項目名稱:Tinyboard,代碼行數:11,代碼來源:anti-bot.php

示例10: make_confusing

 public static function make_confusing($string)
 {
     $chars = preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($chars as &$c) {
         if (mt_rand(0, 3) != 0) {
             $c = utf8tohtml($c);
         } else {
             $c = mb_encode_numericentity($c, array(0, 0xffff, 0, 0xffff), 'UTF-8');
         }
     }
     return implode('', $chars);
 }
開發者ID:odilitime,項目名稱:vichan,代碼行數:12,代碼來源:anti-bot.php

示例11: process

 /**
  * Process contents i.e. insert DropCap at the beginning of the text.
  *
  * @param  string $content The content to be processed
  * @param  array  $options Array of options of how to filter dropcaps
  *
  * @return string          The processed content
  */
 public function process($content, $options)
 {
     // Initialize variables for titling
     $titling = $options->get('titling.enabled');
     $id = md5($content);
     $breakpoints = preg_quote($options->get('titling.breakpoints'), '~');
     $regex = "~.+?(?<=)[{$breakpoints}](?=\\s\\w|\\s*\$)~is";
     // Load PHP built-in DOMDocument class
     if (($dom = $this->loadDOMDocument($content)) === null) {
         return $content;
     }
     // Create a DOM XPath object
     $xpath = new \DOMXPath($dom);
     // Get first paragraph of body element
     $paragraph = $xpath->evaluate('body/p[1]')->item(0);
     // A paragraph should have at least one node with non-empty content
     if (!$paragraph || !$paragraph->hasChildNodes()) {
         return $content;
     }
     $textContent = '';
     $convmap = array(0x80, 0xffff, 0, 0xffff);
     foreach ($paragraph->childNodes as $node) {
         if ($node instanceof \DOMText) {
             // Make sure that content is UTF-8 and entities properly encoded
             $text = htmlspecialchars($node->textContent);
             $text = mb_encode_numericentity($text, $convmap, 'UTF-8');
             $textContent .= $text;
             // Check to match a breakpoint
             if (preg_match($regex, $textContent, $match)) {
                 $textContent = $match[0];
                 break;
             }
         } else {
             // Add placeholder to text
             $textContent .= "{$id}";
         }
         // No breakpoint found...
         if ($paragraph->lastChild === $node) {
             return $content;
         }
     }
     // Replace placeholder with regex for matching a XML/HTML tag
     $re = str_replace("{$id}", '\\s*<\\w+[^>]*>.*?', preg_quote($textContent, '~'));
     $re = '~(<p[^>]*>)\\s*(' . $re . ')~is';
     // Do content replacement
     $content = preg_replace_callback($re, function ($match) use($paragraph, $options, $debugger) {
         $content = $this->insertDropCap($match[2]);
         list($tag, $content) = $this->insertTitling($paragraph, $content, $options->get('titling'));
         return $tag . $content;
     }, $content, 1);
     // Write content back to page
     return $content;
 }
開發者ID:GeoffWilliams,項目名稱:grav-plugin-dropcaps,代碼行數:61,代碼來源:DropCaps.php

示例12: properText

 function properText($text)
 {
     # detect if the string was passed in as unicode
     $text_encoding = mb_detect_encoding($text, 'UTF-8, ISO-8859-1');
     # make sure it's in unicode
     if ($text_encoding != 'UTF-8') {
         $text = mb_convert_encoding($text, 'UTF-8', $text_encoding);
     }
     # html numerically-escape everything (&#[dec];)
     $text = mb_encode_numericentity($text, array(0x0, 0xffff, 0, 0xffff), 'UTF-8');
     return $text;
 }
開發者ID:DEKHTIARJonathan,項目名稱:TEDx-Badge-Generator,代碼行數:12,代碼來源:single_badge_view.php

示例13: utf16Urlencode

 static function utf16Urlencode($str)
 {
     # convert characters > 255 into HTML entities
     $convmap = array(0xff, 0x2ffff, 0, 0xffff);
     $str = mb_encode_numericentity($str, $convmap, "UTF-8");
     # escape HTML entities, so they are not urlencoded
     $str = preg_replace('/&#([0-9a-fA-F]{2,5});/i', 'mark\\1mark', $str);
     $str = urlencode($str);
     # now convert escaped entities into unicode url syntax
     $str = preg_replace('/mark([0-9a-fA-F]{2,5})mark/i', '%u\\1', $str);
     return $str;
 }
開發者ID:jucorant,項目名稱:simple-seo-url,代碼行數:12,代碼來源:language.php

示例14: encode

 public static function encode($value)
 {
     @mb_internal_encoding("UTF-8");
     if (is_int($value)) {
         return (string) $value;
     } elseif (is_string($value)) {
         $value = str_replace(array('\\', '/', '"', "\r", "\n", "\\b", "\f", "\t"), array('\\\\', '\\/', '\\"', '\\r', '\\n', '\\b', '\\f', '\\t'), $value);
         $convmap = array(0x80, 0xffff, 0, 0xffff);
         $result = "";
         for ($i = @mb_strlen($value) - 1; $i >= 0; $i--) {
             $mb_char = @mb_substr($value, $i, 1);
             if (@mb_ereg("&#(\\d+);", @mb_encode_numericentity($mb_char, $convmap, "UTF-8"), $match)) {
                 $result = sprintf("\\u%04x", $match[1]) . $result;
             } else {
                 $result = $mb_char . $result;
             }
         }
         return '"' . $result . '"';
     } elseif (is_float($value)) {
         return str_replace(",", ".", $value);
     } elseif (is_null($value)) {
         return 'null';
     } elseif (is_bool($value)) {
         return $value ? 'true' : 'false';
     } elseif (is_array($value)) {
         $with_keys = false;
         $n = count($value);
         for ($i = 0, reset($value); $i < $n; $i++, next($value)) {
             if (key($value) !== $i) {
                 $with_keys = true;
                 break;
             }
         }
     } elseif (is_object($value)) {
         $with_keys = true;
     } else {
         return '';
     }
     $result = array();
     if ($with_keys) {
         foreach ($value as $key => $v) {
             $result[] = self::encode((string) $key) . ':' . self::encode($v);
         }
         return '{' . implode(',', $result) . '}';
     } else {
         foreach ($value as $key => $v) {
             $result[] = self::encode($v);
         }
         return '[' . implode(',', $result) . ']';
     }
 }
開發者ID:dthiago,項目名稱:tapatalk-mybb,代碼行數:51,代碼來源:classTTJson.php

示例15: _escape

 protected static function _escape($value, $encoding = null)
 {
     $encoding or $encoding = self::_detectEncoding($value);
     if ($encoding === 'UTF-8') {
         # when possible force invisible characters to have some sort of display
         $value = preg_replace('/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\x80-\\x9F]/u', '�', $value);
     }
     $value = htmlspecialchars($value, ENT_QUOTES);
     if (function_exists('mb_encode_numericentity')) {
         return mb_encode_numericentity($value, array(0x80, 0xffff, 0, 0xffff), $encoding);
     } else {
         return $value;
     }
 }
開發者ID:SerdarSanri,項目名稱:arx-core,代碼行數:14,代碼來源:parser.class.php


注:本文中的mb_encode_numericentity函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。