-5

I've searched but still stumped

How do I convert a string with ñ to have the ñ in uppercase too?

e.g.

"Nuñez"

to

"NUÑEZ"

mb_strtoupper is not working due to no english.

Danyal Sandeelo
  • 12,196
  • 10
  • 47
  • 78

1 Answers1

3

You will need to play with encoding.

$content = 'Nuñez';

mb_internal_encoding('UTF-8');
if(!mb_check_encoding($content, 'UTF-8')
OR !($content === mb_convert_encoding(mb_convert_encoding($content, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {

$content = mb_convert_encoding($content, 'UTF-8'); 
}

// NUÑEZ
echo mb_convert_case($content, MB_CASE_UPPER, "UTF-8"); 

via PHP: mb_strtoupper not working

Community
  • 1
  • 1
Danyal Sandeelo
  • 12,196
  • 10
  • 47
  • 78