diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-12-26 11:24:50 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-12-26 11:24:50 -0800 |
commit | 3060a6f662da66008d57a461bf1c9b5b4aa2b002 (patch) | |
tree | 442fd290505817efc0324f2af6e01805cb7396aa /system/core/utf8/substr.php | |
parent | 1cd6a615bb47a33794e4a4f690c87a348ab752d7 (diff) | |
parent | 32d25dafd5b033338b6a9bb8c7c53edab462543a (diff) |
Merge branch 'master' into talmdal_dev
Conflicts:
modules/gallery/controllers/albums.php
modules/gallery/controllers/movies.php
modules/gallery/controllers/photos.php
Diffstat (limited to 'system/core/utf8/substr.php')
-rw-r--r-- | system/core/utf8/substr.php | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/system/core/utf8/substr.php b/system/core/utf8/substr.php deleted file mode 100644 index daf66b81..00000000 --- a/system/core/utf8/substr.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php defined('SYSPATH') OR die('No direct access allowed.'); -/** - * utf8::substr - * - * @package Core - * @author Kohana Team - * @copyright (c) 2007 Kohana Team - * @copyright (c) 2005 Harry Fuecks - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt - */ -function _substr($str, $offset, $length = NULL) -{ - if (SERVER_UTF8) - return ($length === NULL) ? mb_substr($str, $offset) : mb_substr($str, $offset, $length); - - if (utf8::is_ascii($str)) - return ($length === NULL) ? substr($str, $offset) : substr($str, $offset, $length); - - // Normalize params - $str = (string) $str; - $strlen = utf8::strlen($str); - $offset = (int) ($offset < 0) ? max(0, $strlen + $offset) : $offset; // Normalize to positive offset - $length = ($length === NULL) ? NULL : (int) $length; - - // Impossible - if ($length === 0 OR $offset >= $strlen OR ($length < 0 AND $length <= $offset - $strlen)) - return ''; - - // Whole string - if ($offset == 0 AND ($length === NULL OR $length >= $strlen)) - return $str; - - // Build regex - $regex = '^'; - - // Create an offset expression - if ($offset > 0) - { - // PCRE repeating quantifiers must be less than 65536, so repeat when necessary - $x = (int) ($offset / 65535); - $y = (int) ($offset % 65535); - $regex .= ($x == 0) ? '' : '(?:.{65535}){'.$x.'}'; - $regex .= ($y == 0) ? '' : '.{'.$y.'}'; - } - - // Create a length expression - if ($length === NULL) - { - $regex .= '(.*)'; // No length set, grab it all - } - // Find length from the left (positive length) - elseif ($length > 0) - { - // Reduce length so that it can't go beyond the end of the string - $length = min($strlen - $offset, $length); - - $x = (int) ($length / 65535); - $y = (int) ($length % 65535); - $regex .= '('; - $regex .= ($x == 0) ? '' : '(?:.{65535}){'.$x.'}'; - $regex .= '.{'.$y.'})'; - } - // Find length from the right (negative length) - else - { - $x = (int) (-$length / 65535); - $y = (int) (-$length % 65535); - $regex .= '(.*)'; - $regex .= ($x == 0) ? '' : '(?:.{65535}){'.$x.'}'; - $regex .= '.{'.$y.'}'; - } - - preg_match('/'.$regex.'/us', $str, $matches); - return $matches[1]; -}
\ No newline at end of file |