php / php/doc-en

mb_convert_case MB_CASE_TITLE does not actually do Title Case

Open
#3,203 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug Extension: mbstring
Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

Description

The following code:

<?php
$string = "Mrs. Frisby and the Rats of NIMH";
echo mb_convert_case($string, MB_CASE_TITLE);

Resulted in this output:

Mrs. Frisby And The Rats Of Nimh

But I expected this output instead:

Mrs. Frisby and the Rats of NIMH

The function uses the constant MB_CASE_TITLE and the documentation states:

MB_CASE_TITLE (int)
Performs a full title-case conversion based on the Cased and CaseIgnorable derived Unicode properties. In particular this improves handling of quotes and apostrophes. This may change the length of the string.

In the case of my simple example, the function is simply upper-casing each word in the title, and changing all others to lowercase. For proper title casing, the words "and", "the" and "of" should remain lower case. Ideally, the acronym NIMH should remain all caps, but that is a much smaller issue.

PHP Version

PHP 8.2.16

Operating System

Fedora 39

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the PHP documentation entry for mb_convert_case and the definition of MB_CASE_TITLE. Compare the documented Unicode title-case behavior with the reported output and determine whether the wording needs clarification. Done means the documentation accurately describes the function's behavior and the distinction from conventional title capitalization.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.