Req #75108 [Opn]: mb_convert_case lacks ucfirst() mode

From: Date: Thu, 24 Aug 2017 17:42:24 +0000
Subject: Req #75108 [Opn]: mb_convert_case lacks ucfirst() mode
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210798@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75108&edit=1

 ID:                 75108
 Updated by:         kalle@php.net
 Reported by:        chat dot noir at arcor dot de
 Summary:            mb_convert_case lacks ucfirst() mode
 Status:             Open
 Type:               Feature/Change Request
 Package:            mbstring related
 PHP Version:        7.0.22
 Block user comment: N
 Private report:     N

 New Comment:

If added, it might also make sense to implement lcfirst()


Previous Comments:
------------------------------------------------------------------------
[2017-08-23 10:12:18] chat dot noir at arcor dot de

Description:
------------
Three of four ASCII case conversion functions have equivalent modes of mb_convert_case():

1. strtoupper -> MB_CASE_UPPER
2. strtolower -> MB_CASE_LOWER
3. ucwords    -> MB_CASE_TITLE
4. ucfirst    -> ???

What's with the fourth? Would come in handy when you use some dynamic text at the beginning of
a sentence.

Test script:
---------------
/* example by info at yasarnet dot com */
function capitalize($str, $encoding = 'UTF-8') {
    return mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding) .
mb_strtolower(mb_substr($str, 1, mb_strlen($str), $encoding), $encoding);
}



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=75108&edit=1


Thread (2 messages)

« previous php.bugs (#210798) next »