MyBB Community Forums

Full Version: [F] charset - firefox - utf-8 + iso-8859
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
It seems, as if Firefox doesn't understand how to handle the META-Tag "Content-Type". It ignores the additional "charset" specification.

Example:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

If you set your forum to UTF-8 and then post messages with i.e german umlauts, the messages are stored in ISO-8859-1 or ISO-8859-15 in your database.

If you set firefox via the built-in menu to the correct charset (UTF-8) you can see the bogus characters.

But:
Firefox accepts/understands the HTTP-Header "Content-Type" correctly.
So my solution to this problem/bug was to add additional headers before the html output starts (both, in public and in admin area).

Modifikations:

#file - inc/functions.php
function send_page_headers()

{

	global $mybb;
	global $charset;



	if($mybb->settings['nocacheheaders'] == "yes" && $mybb->settings['standardheaders'] != "yes")

	{

		header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");

		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");

		header("Cache-Control: no-cache, must-revalidate");

		header("Pragma: no-cache");

	}
	header("Content-Type: text/html; charset=" . $charset);

}

#file - admin/adminfunctions.php
function cpheader($title="", $donav=1, $onload="", $extraheaders="")

{

	global $mybb, $style, $lang, $cpheader;
	global $charset;



	if($cpheader === true)

	{

    	return true;

  	}



	$cpheader = true;

  	if(!$title)

	{

		$title = $mybb->settings['bbname']." - ".$lang->admin_center;

	}

	$htmltag = "<html>\n";

	if($lang->settings['rtl'] == 1)

	{

		$htmltag = str_replace("<html", "<html dir=\"rtl\"", $htmltag);

	}

	if($lang->settings['htmllang'])

	{

		$htmltag = str_replace("<html", "<html lang=\"".$lang->settings['htmllang']."\"", $htmltag);

	}
	
	header("Content-Type: text/html; charset=" . $charset);

	echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";

	echo $htmltag;

	echo "<head>\n";

	echo "<title>$title</title>\n";

	echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$lang->settings['charset']."\" />\n";

	echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"$style\" />\n";

	echo "<script type=\"text/javascript\">\n";

	echo "function hopto(url) {\n";

	echo "window.location = url;\n";

	echo "}\n";

	echo "</script>\n";

	echo $extraheaders;

	echo "</head>\n";

	if($onload)

	{

		echo "<body onload=\"$onload\">\n";

	}

	else

	{

		echo "<body class=\"main_body\">\n";

	}

	if($donav != 0)

	{

		echo buildacpnav();

	}

}


With greetings from germany,
Minots Esticha
This bug has been fixed in the latest code.

Please note the latest code is not live on the site or for download. An update will be released which contains this fix.

I used another way than yours as we send out different content types when using ajax requests Smile