本文整理汇总了PHP中mb_decode_numericentity函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_decode_numericentity函数的具体用法?PHP mb_decode_numericentity怎么用?PHP mb_decode_numericentity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_decode_numericentity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lookupDecimal
/**
* Given a decimal number, return the UTF-8 character.
*/
public static function lookupDecimal($int)
{
$entity = '&#' . $int . ';';
// UNTESTED: This may fail on some planes. Couldn't find full documentation
// on the value of the mask array.
return mb_decode_numericentity($entity, static::$numeric_mask, 'utf-8');
}
示例2: setup
/**
* Setup: Decode our test strings aheads of time and disable the MultiByte library.
*/
protected function setup()
{
$convmap = array(0x80, 0xffff, 0, 0xffff);
foreach ($this->test_strings as $key => $value) {
$this->test_strings[$key] = mb_decode_numericentity($value, $convmap, 'utf-8');
}
}
示例3: motopressCEJsonEncode
function motopressCEJsonEncode($array)
{
//convmap since 0x80 char codes so it takes all multibyte codes (above ASCII 127). So such characters are being "hidden" from normal json_encoding
$options = array('convmap' => array(0x80, 0xffff, 0, 0xffff), 'encoding' => 'UTF-8');
array_walk_recursive($array, 'motopressCEMbEncodeNumericentity', $options);
return mb_decode_numericentity(json_encode($array), $options['convmap'], $options['encoding']);
}
示例4: stripForForm
/**
* For nicer placement in our textareas - but are we using this really?
* @param string $text
* @param string $process
* @return string
*/
function stripForForm($text = '', $process = '')
{
if (empty($process)) {
// have we checked this yet
if (function_exists('mb_decode_numericentity')) {
return mb_decode_numericentity($text, UTF8EntConvert('1'), 'utf-8');
} else {
$text = htmlspecialchars($text);
return str_replace(array(">", "<"), array(">", "<"), $text);
}
}
if ($text) {
$out = str_replace("<p>", "", $text);
$out = str_replace(array("<br />", "<br>"), array("", ""), $out);
$out = str_replace("</p>", "", $out);
if (function_exists('mb_decode_numericentity')) {
$out = mb_decode_numericentity($out, UTF8EntConvert('1'), 'utf-8');
} else {
$out = htmlspecialchars($out);
$out = str_replace(array(">", "<"), array(">", "<"), $out);
}
return $out;
} else {
return '';
}
}
示例5: 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');
}
示例6: _convertSjisToUtf8
/**
* Convert character encoding from Shift_JIS to UTF-8.
*
* @param string $text
* @return string
*/
function _convertSjisToUtf8($text)
{
$pattern = '/\\x1B\\x24([\\x45-\\x47\\x4F-\\x51][\\x21-\\x7A]+)\\x0F?/';
$callback = array($this, '_convertWebcodeToEntity');
$text = preg_replace_callback($pattern, $callback, $text);
$text = mb_convert_encoding($text, 'UTF-8', 'SJIS-win');
$text = mb_decode_numericentity($text, $this->_utf8map, 'UTF-8');
return $text;
}
示例7: setup
/**
* Setup: Decode our test strings aheads of time and disable the MultiByte library.
*/
protected function setup()
{
$convmap = array(0x80, 0xffff, 0, 0xffff);
foreach ($this->test_strings as $key => $value) {
$this->test_strings[$key] = mb_decode_numericentity($value, $convmap, 'utf-8');
}
// disable using a multibyte library
$this->old_library = MultiByte::library(false);
}
示例8: decodeNumericEntity
public function decodeNumericEntity($text)
{
if (function_exists('mb_decode_numericentity')) {
$convmap = array(0x0, 0x2ffff, 0, 0xffff);
return mb_decode_numericentity($text, $convmap, 'UTF-8');
} else {
return $text;
}
}
示例9: sphinx_keyword
function sphinx_keyword($keyword, $index_data = '')
{
$this->index_data = $index_data ? $index_data : $this->index_data;
//Cắt ngắn
if (mb_strlen($keyword, "UTF-8") > $this->max_keyword_length) {
$keyword = mb_substr($keyword, 0, $this->max_keyword_length, "UTF-8");
}
$this->keyword = mb_strtolower($keyword, "UTF-8");
//echo "2";
//Remove "
$this->keyword = str_replace(""", "", $this->keyword);
//Replace các bad character
$array_bad_word = array("?", "^", ",", ";", "*", "/", "~", "@", "-", "!", "[", "]", "(", ")", "=", "|");
$this->keyword = str_replace($array_bad_word, "", $this->keyword);
//Chống các ký tự ô vuông, convert lại đúng kiểu UTF-8
$this->keyword = mb_convert_encoding($this->keyword, "UTF-8", "UTF-8");
//Xóa bỏ ký tự NCR
$convmap = array(0x0, 0x2ffff, 0, 0xffff);
$this->keyword = @mb_decode_numericentity($this->keyword, $convmap, "UTF-8");
//echo "3";
$j = -1;
//Lấy keyword còn lại sau, bẻ dấu cách
$array_temp = explode(" ", $this->keyword);
for ($i = 0; $i < count($array_temp); $i++) {
if (trim($array_temp[$i]) != "") {
//Những keyword có độ dài > 1 mới cho vào array
if (mb_strlen(trim($array_temp[$i]), "UTF-8") > 1) {
$j++;
$this->array_keyword[$j][0] = str_replace("'", "''", trim($array_temp[$i]));
}
}
}
$quorum = count($array_temp) * 3 / 5;
$quorum = intval($quorum);
if ($quorum < 2) {
$quorum = 2;
}
$this->keyword = trim($this->keyword);
$this->original_keyword = $this->keyword;
//echo $this->keyword;
//Cấu hình sphinx tại localhost
if (@$_SERVER['SERVER_NAME'] == "localhost") {
$this->sphinx_host = "127.0.0.1";
$this->sphinx_port = 9312;
}
//echo "3";
//Khởi tạo class và mở kết nối đến server
$this->sphinx = new SphinxClient();
$this->sphinx->SetServer($this->sphinx_host, $this->sphinx_port);
$this->sphinx->SetConnectTimeout(1.5);
$this->sphinx->SetMatchMode(SPH_MATCH_ANY);
//Lấy max 5030 kết quả trả về
$this->sphinx->_maxmatches = 330;
$this->sphinx->Open();
//echo "4";
}
示例10: 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');
}
示例11: json
function json($data)
{
$CI =& get_instance();
if ($CI->input->is_ajax_request()) {
return json_encode($data);
}
$data = str_replace('<br />', '', $data);
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($val) {
return mb_decode_numericentity('&#' . intval($val[1], 16) . ';', array(0, 0xffff, 0, 0xffff), 'utf-8');
}, json_encode($data));
}
示例12: _convertEntityToUtf8
/**
* Callback function called by the filter() method.
*
* This function converts Unicode hexadecimal number to UTF-8 emoji.
*
* @param array $matches
* @return string
*/
function _convertEntityToUtf8($matches)
{
$unicode = hexdec($matches[1]);
$entity = '&#' . $unicode . ';';
$utf8 = mb_decode_numericentity($entity, $this->_convmap, 'UTF-8');
if ($entity !== $utf8) {
return $utf8;
} else {
return $matches[0];
}
}
示例13: htmldecode
/**
* HTMLデコードした文字列を返す
* @param string $value 対象の文字列
* @return string
*/
public static function htmldecode($value)
{
if (!empty($value) && is_string($value)) {
$value = mb_convert_encoding($value, 'UTF-8', mb_detect_encoding($value));
$value = preg_replace_callback("/&#[xX]([0-9a-fA-F]+);/u", function ($m) {
return '&#' . hexdec($m[1]) . ';';
}, $value);
$value = mb_decode_numericentity($value, array(0x0, 0x10000, 0, 0xfffff), "UTF-8");
$value = html_entity_decode($value, ENT_QUOTES, "UTF-8");
$value = str_replace(array("\\\"", "\\'", "\\\\"), array("\"", "\\'", "\\"), $value);
}
return $value;
}
示例14: fromDecimal
/**
* @param mixed $number
*
* @return string
*/
public static function fromDecimal($number)
{
// Only convert code points within planes 0-2, excluding NULL
if (empty($number) || $number > 0x2ffff) {
return self::fromHex('fffd');
}
$entity = '&#' . $number . ';';
$converted = mb_decode_numericentity($entity, [0x0, 0x2ffff, 0, 0xffff], 'UTF-8');
if ($converted === $entity) {
return self::fromHex('fffd');
}
return $converted;
}
示例15: 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');
}