How to change charset before redirecting

Is it possible for me to change the charset of the page I’m trying to redirect to? Since I can’t pass in more than one header at a time, I’m trying to do something like

// process some stuff here then afterwards
header('Content-Type: text/html; charset=iso-8859-1');
		header('Location: start.php?home=' . strtolower(urlencode($var[0])) . '&away=' . strtolower(urlencode($var[1])));

But each time it redirects to that page, that page loads with utf-8 encoding. How do I go about changing it without something as drastic as a site-wide ini directive converting all documents to iso-8859-1?

I just had an afterthought after my machine went off: instead of redirecting to a new page, I could change the charset, then pull the page using curl or http_request and outputting the string. I think that should work but I can neither test it nor delete this topic (since a solution has been found and the thread redundant) to free up space in the forum.

It is very common mistake, when one confuses Request and Response headers. It will never do like you posted, as Request header makes no sense in the Response.

To send a Request header, you need a client. So your second idea is more plausible, though I have a feeling that your idea on “changing charset” could still be wrong. But as long as you set it with curl request, it would work.

@colshrapnel my friend!! :smile: Long time.

The problem was solved as I earlier described. The only new changes I made was in converting converting the resource back to that format i.e.

header('Content-Type: text/html; charset=iso-8859-1');
	echo(html_entity_decode(file_get_contents($document), ENT_HTML401, 'ISO-8859-1'));

The only problem now is I have to forfeit passing in query strings :frowning:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.