Is it advisable to make character encoding settings configurable for PHP APIs?

It is advisable to make character encoding settings configurable for PHP APIs to ensure compatibility with different systems and to handle various types of input data. By allowing users to specify their preferred character encoding, it can help prevent issues such as data corruption or incorrect display of text.

// Set character encoding based on user-defined configuration
$charset = isset($_GET['charset']) ? $_GET['charset'] : 'UTF-8';
header('Content-Type: text/html; charset=' . $charset);