Merge branch '3.2/develop' of http://github.com/kohana/core into 3.2/develop
[kohana-core.git] / utf8 / ucwords.php
bloba3b7e1bc6528832c0b989d14f595ce9217fdc911
1 <?php defined('SYSPATH') or die('No direct script access.');
2 /**
3 * UTF8::ucwords
5 * @package Kohana
6 * @author Kohana Team
7 * @copyright (c) 2007-2011 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 (UTF8::is_ascii($str))
14 return ucwords($str);
16 // [\x0c\x09\x0b\x0a\x0d\x20] matches form feeds, horizontal tabs, vertical tabs, linefeeds and carriage returns.
17 // This corresponds to the definition of a 'word' defined at http://php.net/ucwords
18 return preg_replace(
19 '/(?<=^|[\x0c\x09\x0b\x0a\x0d\x20])[^\x0c\x09\x0b\x0a\x0d\x20]/ue',
20 'UTF8::strtoupper(\'$0\')',
21 $str