Merge branch 'maint/7.0'
[ninja.git] / system / core / utf8 / ucwords.php
blob2d4c94b6197503718397ec9af90f5d6969811bfc
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3 * utf8::ucwords
5 * @package Core
6 * @author Kohana Team
7 * @copyright (c) 2007 Kohana Team
8 * @copyright (c) 2005 Harry Fuecks
9 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
11 function _ucwords($str)
13 if (SERVER_UTF8)
14 return mb_convert_case($str, MB_CASE_TITLE);
16 if (utf8::is_ascii($str))
17 return ucwords($str);
19 // [\x0c\x09\x0b\x0a\x0d\x20] matches form feeds, horizontal tabs, vertical tabs, linefeeds and carriage returns.
20 // This corresponds to the definition of a 'word' defined at http://php.net/ucwords
21 return preg_replace(
22 '/(?<=^|[\x0c\x09\x0b\x0a\x0d\x20])[^\x0c\x09\x0b\x0a\x0d\x20]/ue',
23 'utf8::strtoupper(\'$0\')',
24 $str