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


PHP mb_internal_encoding函数代码示例

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


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

示例1: parse

 /**
  * Converts a YAML string to a PHP array.
  *
  * @param string  $value                  A YAML string
  * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
  * @param Boolean $objectSupport          true if object support is enabled, false otherwise
  *
  * @return array A PHP array representing the YAML string
  */
 public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false)
 {
     self::$exceptionOnInvalidType = $exceptionOnInvalidType;
     self::$objectSupport = $objectSupport;
     $value = trim($value);
     if (0 == strlen($value)) {
         return '';
     }
     if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) {
         $mbEncoding = mb_internal_encoding();
         mb_internal_encoding('ASCII');
     }
     $i = 0;
     switch ($value[0]) {
         case '[':
             $result = self::parseSequence($value, $i);
             ++$i;
             break;
         case '{':
             $result = self::parseMapping($value, $i);
             ++$i;
             break;
         default:
             $result = self::parseScalar($value, null, array('"', "'"), $i);
     }
     // some comments are allowed at the end
     if (preg_replace('/\\s+#.*$/A', '', substr($value, $i))) {
         throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)));
     }
     if (isset($mbEncoding)) {
         mb_internal_encoding($mbEncoding);
     }
     return $result;
 }
开发者ID:shinichi81,项目名称:Codeigniter-TDD-with-Hooks,代码行数:43,代码来源:Inline.php

示例2: tokenize

 /**
  * Tokenizes a source code.
  *
  * @param  string $code     The source code
  * @param  string $filename A unique identifier for the source code
  *
  * @return Twig_TokenStream A token stream instance
  */
 public function tokenize($code, $filename = 'n/a')
 {
     if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) {
         $mbEncoding = mb_internal_encoding();
         mb_internal_encoding('ASCII');
     }
     $this->code = str_replace(array("\r\n", "\r"), "\n", $code);
     $this->filename = $filename;
     $this->cursor = 0;
     $this->lineno = 1;
     $this->pushedBack = array();
     $this->end = strlen($this->code);
     $this->position = self::POSITION_DATA;
     $tokens = array();
     $end = false;
     while (!$end) {
         $token = $this->nextToken();
         $tokens[] = $token;
         $end = $token->getType() === Twig_Token::EOF_TYPE;
     }
     if (isset($mbEncoding)) {
         mb_internal_encoding($mbEncoding);
     }
     return new Twig_TokenStream($tokens, $this->filename, $this->env->getTrimBlocks());
 }
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:33,代码来源:Lexer.php

示例3: __construct

 public function __construct($params, $encoding = 'utf-8')
 {
     //get parameters
     $this->encoding = $encoding;
     mb_internal_encoding($encoding);
     $this->contents = $this->replace_chars($params['content']);
     // single word
     if (isset($params['min_word_length'])) {
         $this->wordLengthMin = $params['min_word_length'];
     }
     if (isset($params['min_word_occur'])) {
         $this->wordOccuredMin = $params['min_word_occur'];
     }
     // 2 word phrase
     if (isset($params['min_2words_length'])) {
         $this->word2WordPhraseLengthMin = $params['min_2words_length'];
     }
     if (isset($params['min_2words_phrase_length'])) {
         $this->phrase2WordLengthMin = $params['min_2words_phrase_length'];
     }
     if (isset($params['min_2words_phrase_occur'])) {
         $this->phrase2WordLengthMinOccur = $params['min_2words_phrase_occur'];
     }
     // 3 word phrase
     if (isset($params['min_3words_length'])) {
         $this->word3WordPhraseLengthMin = $params['min_3words_length'];
     }
     if (isset($params['min_3words_phrase_length'])) {
         $this->phrase3WordLengthMin = $params['min_3words_phrase_length'];
     }
     if (isset($params['min_3words_phrase_occur'])) {
         $this->phrase3WordLengthMinOccur = $params['min_3words_phrase_occur'];
     }
     //parse single, two words and three words
 }
开发者ID:noikiy,项目名称:amatteur,代码行数:35,代码来源:Keywords.php

示例4: _setupMbstring

 function _setupMbstring()
 {
     #ifdef _MBSTRING_LANGUAGE
     if (defined('_MBSTRING_LANGUAGE') && function_exists("mb_language")) {
         if (@mb_language(_MBSTRING_LANGUAGE) != false && @mb_internal_encoding(_CHARSET) != false) {
             define('MBSTRING', true);
         } else {
             mb_language("neutral");
             mb_internal_encoding("ISO-8859-1");
             if (!defined('MBSTRING')) {
                 define('MBSTRING', false);
             }
         }
         if (function_exists('mb_regex_encoding')) {
             @mb_regex_encoding(_CHARSET);
         }
         ini_set('mbstring.http_input', 'pass');
         ini_set('mbstring.http_output', 'pass');
         ini_set('mbstring.substitute_character', 'none');
     }
     #endif
     if (!defined("MBSTRING")) {
         define("MBSTRING", FALSE);
     }
 }
开发者ID:nbuy,项目名称:legacy,代码行数:25,代码来源:Legacy_LanguageManager.class.php

示例5: h

 /**
  * Convenience method for htmlspecialchars.
  *
  * @param string|array|object $text Text to wrap through htmlspecialchars. Also works with arrays, and objects.
  *    Arrays will be mapped and have all their elements escaped. Objects will be string cast if they
  *    implement a `__toString` method. Otherwise the class name will be used.
  * @param bool $double Encode existing html entities.
  * @param string $charset Character set to use when escaping. Defaults to config value in `mb_internal_encoding()`
  * or 'UTF-8'.
  * @return string Wrapped text.
  * @link http://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#h
  */
 function h($text, $double = true, $charset = null)
 {
     if (is_string($text)) {
         //optimize for strings
     } elseif (is_array($text)) {
         $texts = [];
         foreach ($text as $k => $t) {
             $texts[$k] = h($t, $double, $charset);
         }
         return $texts;
     } elseif (is_object($text)) {
         if (method_exists($text, '__toString')) {
             $text = (string) $text;
         } else {
             $text = '(object)' . get_class($text);
         }
     } elseif (is_bool($text)) {
         return $text;
     }
     static $defaultCharset = false;
     if ($defaultCharset === false) {
         $defaultCharset = mb_internal_encoding();
         if ($defaultCharset === null) {
             $defaultCharset = 'UTF-8';
         }
     }
     if (is_string($double)) {
         $charset = $double;
     }
     return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, $charset ? $charset : $defaultCharset, $double);
 }
开发者ID:m1nd53t,项目名称:cakephp,代码行数:43,代码来源:functions.php

示例6: requiring

 function requiring()
 {
     mb_internal_encoding('UTF-8');
     require_once dirname(__FILE__) . '/config.php';
     if (DB_STORAGE == 'mysql') {
         require_once DIR_LIBRARY . 'connection' . DB_STORAGE . '.php';
     } else {
         require_once DIR_LIBRARY . 'connection.php';
     }
     require_once DIR_LIBRARY . 'validation.php';
     require_once DIR_LIBRARY . 'helper.php';
     require_once DIR_LIBRARY . 'pagination.php';
     require_once DIR_LIBRARY . 'authority.php';
     require_once DIR_LIBRARY . 'filing.php';
     require_once DIR_LIBRARY . 'postcode.php';
     require_once DIR_MODEL . 'model.php';
     require_once DIR_MODEL . 'applicationmodel.php';
     require_once DIR_MODEL . 'config.php';
     require_once DIR_MODEL . 'item.php';
     require_once DIR_VIEW . 'view.php';
     require_once DIR_VIEW . 'applicationview.php';
     require_once DIR_VIEW . 'liquid.php';
     if (get_magic_quotes_gpc()) {
         if (is_array($_POST)) {
             $_POST = $this->strip($_POST);
         }
         if (is_array($_GET)) {
             $_GET = $this->strip($_GET);
         }
     }
 }
开发者ID:rochefort8,项目名称:tt85,代码行数:31,代码来源:controller.php

示例7: configureMBSettings

 /**
  * Configures mbstring settings
  */
 function configureMBSettings($charset)
 {
     $charset = _ml_strtolower($charset);
     $this->_charset = $charset;
     $this->_internal_charset = $charset;
     if (!$this->_mb_enabled) {
         // setting the codepage for mysql connection
         $this->_codepage = $this->getSQLCharacterSet();
         return;
     }
     // getting the encoding for post/get data
     if (_ml_strtolower(ini_get('mbstring.http_input')) == 'pass' || !ini_get('mbstring.encoding_translation')) {
         $data_charset = $charset;
     } else {
         $data_charset = ini_get('mbstring.internal_encoding');
     }
     $this->_internal_charset = 'UTF-8';
     mb_internal_encoding('UTF-8');
     mb_http_output($charset);
     if (!$this->_mb_output) {
         ob_start("mb_output_handler", 8096);
     }
     // setting the codepage for mysql connection
     $this->_codepage = $this->getSQLCharacterSet();
     // checking if get/post data is properly encoded
     if ($data_charset != $this->_internal_charset) {
         convertInputData($this->_internal_charset, $data_charset);
     }
 }
开发者ID:KICHIRO20,项目名称:-Myproject_part1-,代码行数:32,代码来源:multilang_core.php

示例8: index

 public function index()
 {
     define('DEBUG', true);
     // an array of file extensions to accept
     $accepted_extensions = array("png", "jpg", "gif");
     // http://your-web-site.domain/base/url
     $base_url = url::base() . Kohana::config('upload.relative_directory', TRUE) . "jwysiwyg";
     // the root path of the upload directory on the server
     $uploads_dir = Kohana::config('upload.directory', TRUE) . "jwysiwyg";
     // the root path that the files are available from the webserver
     $uploads_access_dir = Kohana::config('upload.directory', TRUE) . "jwysiwyg";
     if (!file_exists($uploads_access_dir)) {
         mkdir($uploads_access_dir, 0775);
     }
     if (DEBUG) {
         if (!file_exists($uploads_access_dir)) {
             $error = 'Folder "' . $uploads_access_dir . '" doesn\'t exists.';
             header('Content-type: text/html; charset=UTF-8');
             print '{"error":"config.php: ' . htmlentities($error) . '","success":false}';
             exit;
         }
     }
     $capabilities = array("move" => false, "rename" => true, "remove" => true, "mkdir" => false, "upload" => true);
     if (extension_loaded('mbstring')) {
         mb_internal_encoding('UTF-8');
         mb_regex_encoding('UTF-8');
     }
     require_once Kohana::find_file('libraries/jwysiwyg', 'common', TRUE);
     require_once Kohana::find_file('libraries/jwysiwyg', 'handlers', TRUE);
     ResponseRouter::getInstance()->run();
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:31,代码来源:filemanager.php

示例9: mb_str_pad

/**
 * found here http://stackoverflow.com/a/11871948
 * @param $input
 * @param $pad_length
 * @param string $pad_string
 * @param int $pad_type
 * @return string
 */
function mb_str_pad($input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT)
{
    mb_internal_encoding('utf-8');
    // @important
    $diff = strlen($input) - mb_strlen($input);
    return str_pad($input, $pad_length + $diff, $pad_string, $pad_type);
}
开发者ID:schmiddim,项目名称:thing-speak-temperatures,代码行数:15,代码来源:cli.php

示例10: StoreFileInfo

 static function StoreFileInfo($file_id, $info)
 {
     global $wpdb;
     self::cleanInfoByRef($info);
     // set encoding to utf8 (required for getKeywords)
     if (function_exists('mb_internal_encoding')) {
         $cur_enc = mb_internal_encoding();
         mb_internal_encoding('UTF-8');
     }
     $keywords = array();
     self::getKeywords($info, $keywords);
     $keywords = strip_tags(join(' ', $keywords));
     $keywords = str_replace(array('\\n', '
'), '', $keywords);
     $keywords = preg_replace('/\\s\\s+/', ' ', $keywords);
     if (!function_exists('mb_detect_encoding') || mb_detect_encoding($keywords, "UTF-8") != "UTF-8") {
         $keywords = utf8_encode($keywords);
     }
     // restore prev encoding
     if (function_exists('mb_internal_encoding')) {
         mb_internal_encoding($cur_enc);
     }
     // don't store keywords 2 times:
     unset($info['keywords']);
     self::removeLongData($info, 8000);
     $data = empty($info) ? '0' : base64_encode(serialize($info));
     $res = $wpdb->replace($wpdb->wpfilebase_files_id3, array('file_id' => (int) $file_id, 'analyzetime' => time(), 'value' => &$data, 'keywords' => &$keywords));
     unset($data, $keywords);
     return $res;
 }
开发者ID:Seravo,项目名称:WP-Filebase,代码行数:29,代码来源:GetID3.php

示例11: escape

 public function escape(array $values)
 {
     if (extension_loaded("mbstring")) {
         $toEnc = defined("SDB_MSSQL_ENCODING") ? SDB_MSSQL_ENCODING : "SJIS";
         $fromEnc = mb_internal_encoding();
         $currentRegexEnc = mb_regex_encoding();
         mb_regex_encoding($fromEnc);
         foreach ($values as $k => &$val) {
             if (is_bool($val)) {
                 $val = $val ? "1" : "0";
             } elseif (is_string($val)) {
                 $val = "'" . mb_convert_encoding(mb_ereg_replace("'", "''", $val), $toEnc, $fromEnc) . "'";
             }
         }
         mb_regex_encoding($currentRegexEnc);
     } else {
         foreach ($values as &$val) {
             if (is_bool($val)) {
                 $val = $val ? "1" : "0";
             } elseif (is_string($val)) {
                 $val = "'" . str_replace("'", "''", $val) . "'";
             }
         }
     }
     return $values;
 }
开发者ID:reoring,项目名称:sabel,代码行数:26,代码来源:Statement.php

示例12: __construct

 public function __construct()
 {
     global $connection;
     mb_internal_encoding('UTF-8');
     mb_regex_encoding('UTF-8');
     $this->link = new mysqli($this->host, $this->username, $this->password, $this->database);
 }
开发者ID:kgrayjr,项目名称:ezleague,代码行数:7,代码来源:class-db.php

示例13: smarty_modifier_mb_truncate

/**
 * Smarty mb_truncate modifier plugin
 *
 * Type:     modifier<br>
 * Name:     mb_truncate<br>
 * Purpose:  Truncate a string to a certain length if necessary,
 *           optionally splitting in the middle of a word, and
 *           appending the $etc string. (MultiByte version)
 * @link http://smarty.php.net/manual/en/language.modifier.truncate.php
 *          truncate (Smarty online manual)
 * @param string
 * @param string
 * @param integer
 * @param string
 * @param boolean
 * @return string
 */
function smarty_modifier_mb_truncate($string, $length = 80, $etc = '...', $break_words = false)
{
    if ($length == 0) {
        return '';
    }
    $string = str_replace("&amp;", "&", $string);
    if (function_exists("mb_internal_encoding") && function_exists("mb_strlen") && function_exists("mb_substr")) {
        mb_internal_encoding("UTF8");
        if (mb_strlen($string) > $length) {
            $length -= mb_strlen($etc);
            if (!$break_words) {
                $string = preg_replace('/\\s+?(\\S+)?$/', '', mb_substr($string, 0, $length + 1));
            }
            $string = mb_substr($string, 0, $length) . $etc;
        }
    } else {
        //modifier.truncate
        if (strlen($string) > $length) {
            $length -= strlen($etc);
            if (!$break_words) {
                $string = preg_replace('/\\s+?(\\S+)?$/', '', substr($string, 0, $length + 1));
            }
            $string = substr($string, 0, $length) . $etc;
        }
    }
    $string = str_replace("&", "&amp;", $string);
    return $string;
}
开发者ID:ber5ien,项目名称:www.jade-palace.co.uk,代码行数:45,代码来源:modifier.mb_truncate.php

示例14: __construct

 public function __construct($debug = 0, $maxpass = 50)
 {
     global $modx;
     $this->name = "PHx";
     $this->version = "2.2.0";
     $this->user["mgrid"] = isset($_SESSION['mgrInternalKey']) ? intval($_SESSION['mgrInternalKey']) : 0;
     $this->user["usrid"] = isset($_SESSION['webInternalKey']) ? intval($_SESSION['webInternalKey']) : 0;
     $this->user["id"] = $this->user["usrid"] > 0 ? -$this->user["usrid"] : $this->user["mgrid"];
     $this->cache["cm"] = array();
     $this->cache["ui"] = array();
     $this->cache["mo"] = array();
     $this->safetags[0][0] = '~(?<![\\[]|^\\^)\\[(?=[^\\+\\*\\(\\[]|$)~s';
     $this->safetags[0][1] = '~(?<=[^\\+\\*\\)\\]]|^)\\](?=[^\\]]|$)~s';
     $this->safetags[1][0] = '&_PHX_INTERNAL_091_&';
     $this->safetags[1][1] = '&_PHX_INTERNAL_093_&';
     $this->safetags[2][0] = '[';
     $this->safetags[2][1] = ']';
     $this->console = array();
     $this->debug = $debug != '' ? $debug : 0;
     $this->debugLog = false;
     $this->curPass = 0;
     $this->maxPasses = $maxpass != '' ? $maxpass : 50;
     $this->swapSnippetCache = array();
     $modx->setPlaceholder("phx", "&_PHX_INTERNAL_&");
     if (function_exists('mb_internal_encoding')) {
         mb_internal_encoding($modx->config['modx_charset']);
     }
 }
开发者ID:dukeRD,项目名称:DocLister,代码行数:28,代码来源:DLphx.class.php

示例15: loadquestion

    public function loadquestion()
    {
        $session = new Zend_Session_Namespace('game');
        $formQuesten = new Application_Form_LoadQuestion($_POST);
        $this->view->formQuesten = $formQuesten;
        $session->success = 0;
        $success = null;
        $question = "";
        $answer = "";
        $session->success = 0;
        mb_regex_encoding('UTF-8');
        mb_internal_encoding("UTF-8");
        $db = Zend_Registry::get('dbc');
        $db->query('SET NAMES utf8;');
        if (!is_null($db)) {
            $stmt = $db->prepare('SELECT german, english FROM vocable
								WHERE (level = "' . $session->level . '")
								ORDER BY RAND()
								LIMIT 1');
            $stmt->execute();
            $stmt->bind_result($question, $answer);
            $ergebnis = array();
            $i = 0;
            // Array ausgeben
            while ($stmt->fetch()) {
                $ergebnis[$i][0] = $question;
                $ergebnis[$i][1] = $answer;
                $i++;
            }
            $stmt->close();
            return $ergebnis;
        }
    }
开发者ID:rlechner,项目名称:wtprojekt,代码行数:33,代码来源:GameController.php


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