Response Content type "text/xml" without ";charset=UTF-8"

How can I remove the “charset=UTF-8” from the Content type? I want to get Content-Type as “text/xml” without the “charset=UTF-8”

this is my code
$rta = ReadXML($parameters);
$response = $response->write($rta);
$response = $response->withHeader(‘Content-type’, ‘text/xml’);
return $response;
But php automatically add charset=UTF-8

Yes, correct PHP sends the Content-Type charset header value automatically, if you not set it directly in into your response object. PHP uses the value from this ini setting:

ini_set('default_charset', 'utf-8');

If you set this value to an empty string, PHP will not add charset=UTF-8 to the response.

ini_set('default_charset', '');

In the long run, it would be better to explicitly define your specific charset. For example, if your XML content is not UTF-8, it is better to send it instead of omitting it. For example:

$response = $response->withHeader('Content-Type', 'text/xml; charset=ISO-8859-1');