• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mb_encode_numericentity函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了mb_encode_numericentity函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: toNumericEntities

 /**
  * Méthode static d'encodage récursif de valeurs dans leurs valeur numériques (é ==> &#233;)
  * @static
  * @param mixed $pValue
  * @return string|array
  */
 public static function toNumericEntities($pValue)
 {
     $convmap = array(0x80, 0xff, 0, 0xff);
     if (is_object($pValue)) {
         return $pValue;
     }
     if (!is_array($pValue)) {
         return mb_encode_numericentity($pValue, $convmap, Configuration::$global_encoding);
     }
     foreach ($pValue as &$value) {
         $value = self::toNumericEntities($value);
     }
     return $pValue;
 }
开发者ID:arno06,项目名称:Achilles,代码行数:20,代码来源:class.Encoding.php


示例17: associativeArrayToJsonStr

 /**
  * @author devilan (REMOVEIT) (at) o2 (dot) pl
  * For PHP5.3 users who want to emulate JSON_UNESCAPED_UNICODE
  * @see https://php.net/manual/en/function.json-encode.php#105789
  */
 public static function associativeArrayToJsonStr($arr, $optionsBitMask = 0)
 {
     if (defined('JSON_UNESCAPED_UNICODE')) {
         return json_encode($arr, JSON_UNESCAPED_UNICODE | $optionsBitMask);
     }
     $convmap = array(0x80, 0xffff, 0, 0xffff);
     //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) use(&$convmap) {
         if (is_string($item)) {
             $item = mb_encode_numericentity($item, $convmap, 'UTF-8');
         }
     });
     return mb_decode_numericentity(json_encode($arr, $optionsBitMask), $convmap, 'UTF-8');
 }
开发者ID:billforward,项目名称:bf-php,代码行数:19,代码来源:Utility.php


示例18: json_encode_string

/**
 * Special handling for multibyte strings (e.g. Unicode)
 *
 * @param string $in_str
 * @return JSON-encoded string
 */
function json_encode_string($in_str)
{
    mb_internal_encoding("UTF-8");
    $convmap = array(0x80, 0xffff, 0, 0xffff);
    $result = "";
    for ($i = mb_strlen($in_str) - 1; $i >= 0; $i--) {
        $mb_char = mb_substr($in_str, $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;
}
开发者ID:justinlyon,项目名称:scc,代码行数:21,代码来源:json_encode.php


示例19: parseParameters

 protected function parseParameters($parameters)
 {
     if (!empty($parameters) && is_array($parameters)) {
         $object = new stdClass();
         $parent = $this->getParent();
         $object->{$parent} = new stdClass();
         $parent = $object->{$parent};
         if ($this->actionInclude('/reorder')) {
             foreach ($parameters as $id) {
                 $item = new stdClass();
                 $item->id = $id;
                 $parent->{$this->parent}[] = $item;
             }
         } else {
             foreach ($this->fields as $field => $options) {
                 $value = $this->getValue($field, $options, $parameters);
                 if (isset($options['attributes'])) {
                     foreach ($options['attributes'] as $name => $type) {
                         if (null !== $value) {
                             if ($name === 'type') {
                                 if ($type === 'array') {
                                     if (is_string($value) || is_numeric($value)) {
                                         $value = (array) $value;
                                     } else {
                                         $value = null;
                                     }
                                 } else {
                                     settype($value, $type);
                                 }
                             }
                         }
                     }
                 }
                 if (null !== $value) {
                     if (is_string($value)) {
                         $value = mb_encode_numericentity($value, [0x80, 0xffff, 0, 0xffff], 'utf-8');
                     }
                     !empty($options['sibling']) ? $object->{$field} = $value : ($parent->{$field} = $value);
                 }
             }
         }
         $parameters = json_encode($object);
         $parameters = mb_decode_numericentity($parameters, [0x80, 0xffff, 0, 0xffff], 'utf-8');
     } else {
         $parameters = '{}';
     }
     return $parameters;
 }
开发者ID:theboxer,项目名称:TeamWorkPmPhpApi,代码行数:48,代码来源:JSON.php


示例20: superentities

function superentities($str)
{
    // get rid of existing entities else double-escape
    $str = html_entity_decode(stripslashes($str), ENT_QUOTES, 'UTF-8');
    $ar = preg_split('/(?<!^)(?!$)/u', $str);
    // return array of every multi-byte character
    foreach ($ar as $c) {
        $o = ord($c);
        if (strlen($c) > 1 || ($o < 32 || $o > 126) || $o > 33 && $o < 40 || $o > 59 && $o < 63) {
            // convert to numeric entity
            $c = mb_encode_numericentity($c, array(0x0, 0xffff, 0, 0xffff), 'UTF-8');
        }
        $str2 .= $c;
    }
    return $str2;
}
开发者ID:bestwishforyou95,项目名称:tiennam,代码行数:16,代码来源:func.lib.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mb_ereg函数代码示例发布时间:2022-05-15
下一篇:
PHP mb_encode_mimeheader函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap