php / php/php-src

MB_CASE_TITLE treats entities as words (in contrast to uc_words)

Open
#18,236 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Extension: mbstring Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

The following code:

<?php
$txt = 'acme &amp; co';

echo mb_convert_case($txt, MB_CASE_TITLE, 'UTF-8'), PHP_EOL;

Resulted in this output:

Acme &Amp; Co

But I expected this output instead:

Acme &amp; Co

Using uc_words produces the expected result:

<?php
$txt = 'acme &amp; co';

echo ucwords($txt), PHP_EOL;

results in

Acme &amp; Co
PHP Version

PHP 8.4.5, PHP 8.2.26

Operating System

No response

Contributor guide

Open the contributing guide

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 with the mb_convert_case entry point and reproduce the reported PHP 8.4.5 and 8.2.26 behavior using the supplied acme & co example. The work is done when title casing preserves the entity as & while still producing Acme and Co, with regression coverage for the reported input.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
internationalization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.