why the php ucfirst error, why?

230 Views Asked by At

@see: (on mac os):

developer:php $ php -v

PHP 5.5.24 (cli) (built: Apr 27 2015 11:18:18) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

developer:php $ php -r "echo ucfirst('the test') . PHP_EOL;"

The test

developer:php $ php -r "echo ucfirst('中文') . PHP_EOL;"

ĸ?文 <<<<

Please help me , 3Q!

PS: php5.6 is same!

1

There are 1 best solutions below

1
Jason Byrne On

I think this is a charset encoding thing where you need a multi-byte function. This other question says there is no mb_ucfirst but has a solution listed:

ucfirst() function for multibyte character encodings