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


PHP Dwoo::getCharset方法代码示例

本文整理汇总了PHP中Dwoo::getCharset方法的典型用法代码示例。如果您正苦于以下问题:PHP Dwoo::getCharset方法的具体用法?PHP Dwoo::getCharset怎么用?PHP Dwoo::getCharset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dwoo的用法示例。


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

示例1: Dwoo_Plugin_capitalize

/**
 * Capitalizes the first letter of each word
 * <pre>
 *  * value : the string to capitalize
 *  * numwords : if true, the words containing numbers are capitalized as well
 * </pre>
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from the use of this software.
 *
 * @author     Jordi Boggiano <j.boggiano@seld.be>
 * @copyright  Copyright (c) 2008, Jordi Boggiano
 * @license    http://dwoo.org/LICENSE   Modified BSD License
 * @link       http://dwoo.org/
 * @version    1.1.0
 * @date       2009-07-18
 * @package    Dwoo
 */
function Dwoo_Plugin_capitalize(Dwoo $dwoo, $value, $numwords = false)
{
    if ($numwords || preg_match('#^[^0-9]+$#', $value)) {
        return mb_convert_case((string) $value, MB_CASE_TITLE, $dwoo->getCharset());
    } else {
        $bits = explode(' ', (string) $value);
        $out = '';
        while (list(, $v) = each($bits)) {
            if (preg_match('#^[^0-9]+$#', $v)) {
                $out .= ' ' . mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset());
            } else {
                $out .= ' ' . $v;
            }
        }
        return substr($out, 1);
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:34,代码来源:capitalize.php

示例2: Dwoo_Plugin_reverse

/**
 * Reverses a string or an array
 * <pre>
 *  * value : the string or array to reverse
 *  * preserve_keys : if value is an array and this is true, then the array keys are left intact
 * </pre>
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from the use of this software.
 *
 * @author     Jordi Boggiano <j.boggiano@seld.be>
 * @copyright  Copyright (c) 2008, Jordi Boggiano
 * @license    http://dwoo.org/LICENSE   Modified BSD License
 * @link       http://dwoo.org/
 * @version    1.0.0
 * @date       2008-10-23
 * @package    Dwoo
 */
function Dwoo_Plugin_reverse(Dwoo $dwoo, $value, $preserve_keys = false)
{
    if (is_array($value)) {
        return array_reverse($value, $preserve_keys);
    } elseif (($charset = $dwoo->getCharset()) === 'iso-8859-1') {
        return strrev((string) $value);
    } else {
        $strlen = mb_strlen($value);
        $out = '';
        while ($strlen--) {
            $out .= mb_substr($value, $strlen, 1, $charset);
        }
        return $out;
    }
}
开发者ID:netfreak,项目名称:pyrocms,代码行数:32,代码来源:reverse.php

示例3: Dwoo_Plugin_escape

/**
 * Applies various escaping schemes on the given string
 * <pre>
 *  * value : the string to process
 *  * format : escaping format to use, valid formats are : html, htmlall, url, urlpathinfo, quotes, hex, hexentity, javascript and mail
 *  * charset : character set to use for the conversion (applies to some formats only), defaults to the current Dwoo charset
 * </pre>
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from the use of this software.
 *
 * @author     Jordi Boggiano <j.boggiano@seld.be>
 * @copyright  Copyright (c) 2008, Jordi Boggiano
 * @license    http://dwoo.org/LICENSE   Modified BSD License
 * @link       http://dwoo.org/
 * @version    1.0.0
 * @date       2008-10-23
 * @package    Dwoo
 */
function Dwoo_Plugin_escape(Dwoo $dwoo, $value = '', $format = 'html', $charset = null)
{
    if ($charset === null) {
        $charset = $dwoo->getCharset();
    }
    switch ($format) {
        case 'html':
            return htmlspecialchars((string) $value, ENT_QUOTES, $charset);
        case 'htmlall':
            return htmlentities((string) $value, ENT_QUOTES, $charset);
        case 'url':
            return rawurlencode((string) $value);
        case 'urlpathinfo':
            return str_replace('%2F', '/', rawurlencode((string) $value));
        case 'quotes':
            return preg_replace("#(?<!\\\\)'#", "\\'", (string) $value);
        case 'hex':
            $out = '';
            $cnt = strlen((string) $value);
            for ($i = 0; $i < $cnt; $i++) {
                $out .= '%' . bin2hex((string) $value[$i]);
            }
            return $out;
        case 'hexentity':
            $out = '';
            $cnt = strlen((string) $value);
            for ($i = 0; $i < $cnt; $i++) {
                $out .= '&#x' . bin2hex((string) $value[$i]) . ';';
            }
            return $out;
        case 'javascript':
            return strtr((string) $value, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\\/'));
        case 'mail':
            return str_replace(array('@', '.'), array('&nbsp;(AT)&nbsp;', '&nbsp;(DOT)&nbsp;'), (string) $value);
        default:
            return $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "' . $format . '" given.', E_USER_WARNING);
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:56,代码来源:escape.php


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