What are some best practices for handling character encoding issues when working with files in PHP?

Character encoding issues can arise when working with files in PHP, especially when dealing with non-ASCII characters. To handle these issues, it is important to ensure that the correct encoding is used when reading or writing files. One common approach is to use functions like `mb_convert_encoding()` to convert the encoding of strings as needed.

// Specify the encoding when reading a file
$fileContents = file_get_contents('example.txt', false, null, -1, 100, 'UTF-8');

// Convert encoding of a string
$convertedString = mb_convert_encoding($originalString, 'UTF-8', 'ISO-8859-1');