# mb_ucfirst and mb_lcfirst

- Thread: https://externals.io/message/120409
- Original archive: https://news-web.php.net/php.internals/120409
- Started by Niels Dossche on 2023-05-27T21:11:39+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #120409 — Niels Dossche — 2023-05-27T21:11:39+00:00

URL: https://externals.io/message/120409#120409

Hey internals

I recently saw a comment on Reddit about the lack of a multibyte version of ucfirst and lcfirst.
I was surprised to see this is indeed the case.
I also checked the modes of mb_convert_case: the closest supported one is title case, but there's no mode for only handling the first letter.

I have two questions (and some sub-questions):
Does anyone know if there is a historical reason for this? A quick search on externals.io didn't provide something useful.
Do you think this is useful? If yes, do you think this should be part of mb_convert_case or should this be a standalone function?

Kind regards
Niels

---

## #120413 — Hans Henrik Bergan — 2023-05-28T07:33:57+00:00

URL: https://externals.io/message/120409#120413 · In reply to: #120409

I think it would be useful.
For some reason, lots of people on stackoverflow has a hard time
implementing this function in userland:
on https://stackoverflow.com/questions/2517947/ucfirst-function-for-multibyte-character-encodings
there are 10 broken implementations of mb_ucfirst, and 1 correct one
(disclaimer: I only consider my own implementation correct:
https://stackoverflow.com/a/58915632/1067003
and consider every other implementation on the list broken in one way
or another. and i was really surprised that nobody else got it right.)


>
> Hey internals
>
> I recently saw a comment on Reddit about the lack of a multibyte version of ucfirst and lcfirst.
> I was surprised to see this is indeed the case.
> I also checked the modes of mb_convert_case: the closest supported one is title case, but there's no mode for only handling the first letter.
>
> I have two questions (and some sub-questions):
> Does anyone know if there is a historical reason for this? A quick search on externals.io didn't provide something useful.
> Do you think this is useful? If yes, do you think this should be part of mb_convert_case or should this be a standalone function?
>
> Kind regards
> Niels
>
> --
> 
> To unsubscribe, visit: https://www.php.net/unsub.php
