Re: Re: ucwords() vs title case
| From: | Andrea Faulds | Date: | Mon, 30 Jun 2014 11:57:37 +0000 |
| Subject: | Re: Re: ucwords() vs title case | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75141@lists.php.net to get a copy of this message | ||
On 30 Jun 2014, at 12:54, Tjerk Meesters <tjerk.meesters@gmail.com> wrote:
> Hi internals,
>
> I came across this old bug:
> https://bugs.php.net/bug.php?id=34407
>
> The desired behaviour for that particular person:
>
> "the (world) now" => "The (World) Now"
>
> Currently PHP adopts a very simple rule:
> 1. Capitalise first character (no matter what it is)
> 2. Capitalise character preceded by a space, tab, etc.
>
> Using string.title() from Python you'd get the expected behaviour; they use:
> 1. Capitalise first letter of a word
> 2. Lowercase subsequent letters of a word
> 3. Non-letters delimit words
>
> Personally I find that the latter is too much of a departure from what we
> currently have; a compromise could be to treat punctuation as a word
> delimiter.
Hmm. Why not make it follow what \b in a regex would do, looking for “word boundaries”?
--
Andrea Faulds
http://ajf.me/