How can I use strtoupper in PHP to convert a UTF-8 string to uppercase?

Solution:

To handle uppercase conversion with full Unicode support, use mb_strtoupper:


<?php
$str = "Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
$str = mb_strtoupper($str, "UTF-8");
echo $str;  
// Output: ΤΆΧΙΣΤΗ ΑΛΏΠΗΞ ΒΑΦΉΣ ΨΗΜΈΝΗ ΓΗ, ΔΡΑΣΚΕΛΊΖΕΙ ΥΠΈΡ ΝΩΘΡΟΎ ΚΥΝΌΣ
?>

According to PHP.net:

Unlike the standard case-conversion functions (strtolower(), strtoupper()), mb_strtoupper() applies Unicode-aware case folding. This means:

It is not affected by locale settings.

It can convert all alphabetic characters, including special ones such as Ä (A-umlaut).