What are the best practices for handling multi-byte characters in PHP to avoid display issues?

When working with multi-byte characters in PHP, it is important to use multibyte string functions to properly handle and manipulate these characters. This helps avoid display issues such as garbled text or incorrect string length calculations. One common practice is to set the internal encoding to UTF-8 using mb_internal_encoding() function and use mb_* functions for string operations.

// Set internal encoding to UTF-8
mb_internal_encoding('UTF-8');

// Use mb_strlen() instead of strlen()
$length = mb_strlen($string);

// Use mb_substr() instead of substr()
$substring = mb_substr($string, 0, 5);

// Use mb_convert_encoding() for encoding conversions
$convertedString = mb_convert_encoding($string, 'UTF-8', 'ISO-8859-1');