Exemplo n.º 1
0
 /**
  * Find the related code folding values for $char
  *
  * @param integer $char decimal value of character
  * @param string $type
  * @return array
  */
 protected static function _find($char, $type = 'lower')
 {
     $found = array();
     if (!isset(self::$_codeRange[$char])) {
         $range = self::_codepoint($char);
         if ($range === false) {
             return null;
         }
         if (!Configure::configured('_cake_core_')) {
             App::uses('PhpReader', 'Configure');
             Configure::config('_cake_core_', new PhpReader(CAKE . 'Config' . DS));
         }
         Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_');
         self::$_caseFold[$range] = Configure::read($range);
         Configure::delete($range);
     }
     if (!self::$_codeRange[$char]) {
         return null;
     }
     self::$_table = self::$_codeRange[$char];
     $count = count(self::$_caseFold[self::$_table]);
     for ($i = 0; $i < $count; $i++) {
         if ($type === 'lower' && self::$_caseFold[self::$_table][$i][$type][0] === $char) {
             $found[] = self::$_caseFold[self::$_table][$i];
         } elseif ($type === 'upper' && self::$_caseFold[self::$_table][$i][$type] === $char) {
             $found[] = self::$_caseFold[self::$_table][$i];
         }
     }
     return $found;
 }
Exemplo n.º 2
0
 /**
  * Multibyte wrapper for strftime.
  *
  * Handles utf8_encoding the result of strftime when necessary.
  *
  * @param string $format Format string.
  * @param integer $date Timestamp to format.
  * @return string formatted string with correct encoding.
  */
 protected static function _strftime($format, $date)
 {
     $format = strftime($format, $date);
     $encoding = Configure::read('App.encoding');
     if (!empty($encoding) && $encoding === 'UTF-8') {
         if (function_exists('mb_check_encoding')) {
             $valid = mb_check_encoding($format, $encoding);
         } else {
             $valid = !YdCakeMultibyte::checkMultibyte($format);
         }
         if (!$valid) {
             $format = utf8_encode($format);
         }
     }
     return $format;
 }