Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ucfirst

Uppercases the first character of a string.

Returns a copy of STRING with the first character converted to uppercase and all other characters left unchanged. For ASCII first characters, a single-byte in-place mutation is used. For Unicode first characters, to_uppercase() may produce multiple characters (e.g. the ffi ligature U+FB03).

Returns an empty string when given an empty string.

Synopsis

$result = ucfirst($string);
$result = ucfirst('hello');   # "Hello"

Implementation Notes

perl5 reference: pp.c:4100 S_do_ucfirst (shared ucfirst/lcfirst function). Non-UTF-8 locale path: use libc::toupper on first byte. perl5: pp.c:4228-4243 – toLOWER_LC / toUPPER_LC for first byte.

See Also

PP runtime: ucfirst | lcfirst, uc, lc