コード例 #1
0
/**
 * Sets/Gets internal character encoding of the regular expression functions (ereg-like) within the PHP mbstring extension.
 * @param string $encoding (optional)	When this parameter is given, the function sets the internal encoding.
 * @return string						When $encoding parameter is not given, the function returns the internal encoding.
 * Note: This function is used in the global initialization script for setting the internal encoding to the platform's character set.
 * @link http://php.net/manual/en/function.mb-regex-encoding
 */
function _api_mb_regex_encoding($encoding = null)
{
    static $mb_regex_encoding = null;
    if (empty($encoding)) {
        if (is_null($mb_regex_encoding)) {
            if (MBSTRING_INSTALLED) {
                $mb_regex_encoding = @mb_regex_encoding();
            } else {
                $mb_regex_encoding = 'UTF-8';
            }
        }
        return $mb_regex_encoding;
    }
    $mb_regex_encoding = $encoding;
    if (_api_mb_supports($encoding)) {
        return @mb_regex_encoding($encoding);
    }
    return false;
}
コード例 #2
0
/**
 * Checks whether a specified encoding is supported by this API.
 * @param string $encoding    The specified encoding.
 * @return bool                Returns TRUE when the specified encoding is supported, FALSE othewise.
 */
function api_is_encoding_supported($encoding)
{
    static $supported = array();
    if (!isset($supported[$encoding])) {
        $supported[$encoding] = _api_mb_supports($encoding) || _api_iconv_supports($encoding) || _api_convert_encoding_supports($encoding);
    }
    return $supported[$encoding];
}