FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


ob_start("ob_gzhandler")





inphurno
Hi everyone,

when i use ob_start("ob_gzhandler"); to gzip my pages the character encoding of the page ends up to be utf-8, is this normal? The pages themselves are in ANSI when I check in notepad++. So is there some setting somewhere that I can change so that the page doesnt come out in utf-8 or is this a server setting?

thanks in advance Very Happy

edit: 300th post!
inphurno
Does anyone out there know the answer to this one? Is there any important info missing in my post? Any help on this one would be great Smile
imagefree
can u share the html here? (Just the head portion)
inphurno
here is the head from: http://www.whatsyourimpact.eu.org/what-can-i-do.php

<head>

<title>How can I fight climate change? Use our 5 easy tips everyday! | WYI?</title>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="content-language" content="en" />
<meta name="author" content="WhatsYourImpact.eu.org" />
<meta name="description" content="Buying local, driving less, using less electricity or green energy, buying less/smart and explaining this to others is all it takes to reduce your emissions everyday!" />
<meta name="keywords" content="what is your impact climate change greenhouse gas emission fossil fuels main sources do buy local drive less green energy" />

<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow" />
<meta name="robots" content="all" />

<link rel="stylesheet" type="text/css" media="screen" href="style/style.css.php"/>

<link rel="icon" type="image/png" href="style/favicon.ico" />

<script language="JavaScript" type="text/javascript">
try {
document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
</script>

<!--[if gte IE 5.5]>
<![if lt IE 7]>
<style type="text/css">
#alImg1 img, #alImg2 img { filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0); }
#alImg1, #alImg2 { display: inline-block; }
#alImg1 { filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='style/32x32-digg-guy.png'); }
#alImg2 { filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='style/connect.png'); }
</style>
<![endif]>
<![endif]-->
</head>
imagefree
i have tested it in Opera's side panel with and without providing the <meta> encoding while using output compression. It doesnt change the Character Encoding (CE) automatically, neither do the browser assume it when the CE is not provided by server. there must be some other problem.
inphurno
with or without this: <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> it shouldnt make a difference since this means expect iso-8859-1. You could still have a page in utf with this in the head that would probably work. i'm assuning some kind of magic is done on the php side to transform the gzip content into utf but otherwise i dont know what could be causing this
imagefree
try this at the top of your page:

Code:
<?php header('Content-type: text/html; charset=iso-8859-1'); ?>


and reply.
inphurno
I tried what you said and it was still coming out in utf. here is the code that i have maybe this will help:

<?php
header('Content-type: text/html; charset=iso-8859-1');
function isBuggyIe() {
$ua = $_SERVER['HTTP_USER_AGENT'];
// quick escape for non-IEs
if (0 !== strpos($ua, 'Mozilla/4.0 (compatible; MSIE ')
|| false !== strpos($ua, 'Opera')) {
return false;
}
// no regex = faaast
$version = (float)substr($ua, 30);
return (
$version < 6
|| ($version == 6 && false === strpos($ua, 'SV1'))
);
}

if( strstr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')!==false || strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')===false ){
// do not compress
}else{
// can send GZIP compressed data
isBuggyIe() || ob_start("ob_gzhandler");
}
?>
imagefree
this is what i am getting in your response headers:

Code:
Content-Type   text/html; charset=UTF-8

(Seen in FireBug)
inphurno
Very Happy

if i comment out this line: isBuggyIe() || ob_start("ob_gzhandler");
and keep the same code the page comes out in iso-8859-1

Does the order matter, what I mean is if i put the header command before the ob_start("ob_gzhandler"); or vice versa does this affect anything? I'm just trying to understand why the header is not being set. Also i don't have a call to ob_flush at the end of my script, I don't know if this is a prob.
inphurno
can anyone help further on this problem?
imagefree
inphurno wrote:
can anyone help further on this problem?


open your file in notepad ++, click Format Menu and change your Encoding Option.
inphurno
the files are in ansi, what encoding option should i use?
imagefree
its strange. I cant tell you any solution. However your script might be sending the content type header somewhere deep inside your script, or may be .htaccess file is doing so, or the http.conf
not sure.
inphurno
i just did a find in files through all of my pages for "utf" and "header(" and the only place where i set the charset is here: header('Content-type: text/html; charset=iso-8859-1');

in my htaccess there is no utf and i dont think we have access to the httpd.conf file here at frihost.

maybe i can set the charset in the htaccess and convert all my files to utf in notepad++
what is the diff between utf with and without BOM?
inphurno
any one knows the difference between utf with and without BOM?
imagefree
http://en.wikipedia.org/wiki/Byte-order_mark
Related topics
HELP: setcookie() and header problems
Site Nav Suggestions...
Sessions
Submission Forms
Redirection
php script in php nuke - need help!
MySQL DB Backup script - minor problem
PHP script has MSQL access denied
Guys, HELP!!! Script wanted!
How To: Easily Save Your Bandwidth Using GZIP
How to save HTML in Databases wise ly ?
problem when using ob_start("ob_gzhandler") on php
is eAccelerator installed on server2?
Site load in half time (with no browser compatibility issue)
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.