1

Hi All in phpinfo page I find the charset is UTF-8. Content-Type text/html; charset=UTF-8 I want to remove the charset to null witout changing in php.ini file is it possible.

2
  • have you try header("Content-Type text/html; charset=ANY_THING_THAT_NOT_STANDARD_CHRSET") ? Commented May 27, 2011 at 9:39
  • 1
    There is no such thing as a "null charset". Commented May 27, 2011 at 9:41

5 Answers 5

3

You can set on top of your file ini_set("default_charset", "");

Sign up to request clarification or add additional context in comments.

1 Comment

Or .htaccess >>> php_value default_charset null
3

A "null charset" is the same as ISO-8859-1 according to RFC 2616:

When no explicit charset parameter is provided by the sender, media subtypes of the "text" type are defined to have a default charset value of "ISO-8859-1" when received via HTTP.

Setting the charset to ISO-8859-1 is therefore the same as not setting any charset at all. However, since Google Chrome implements this wrong (they default to UTF-8) you should really consider to explicitly set the charset to ISO-8859-1 (or whichever charset you are using).

5 Comments

This is theoretically the correct answer; note that due to a myriad of sloppy webpages, this is not entirely true in practice; most browsers do some sort of charset sniffing to determine the probable charset.
Most browsers get it wrong when they try to sniff the charset, so the best bet is still to set it explicitly.
It's indeed best to set it explicitly; but the majority of sniffing actually gets it right (so the user doesn't even notice). However, when the heuristic fails, the results are highly visible, which leads to the assumption "it usually fails". Yes, it's a last-resort fallback measure, and yes, the server should know and advertise what charset it's using. Alas, there are still broken sites - and users perceive this as broken browser instead.
I've seen numerous sites where the browsers guess for UTF-8 when it should be ISO-8859-1. I consider that a broken browser.
If a browser defaults to an encoding that's not ISO-8859-1, it is also broken. What I meant are sites that send conflicting data: no charset specified in headers, one charset specified in meta tags, different charest actually used. That used to be quite common, fortunately it's slowly going away.
1

If you have the privileges to do so, you can override INI settings on a per-script basis. Otherwise you can simply output an overriding header: header("Content-type: text/html; charset=ISO-8859-1"); or include it directly in your HTML output as <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />, obviously replacing ISO-8859-1 with whatever you want.

1 Comment

He wanted to be nothing, no utf8 nor iso-8859-1. It's strange to me, but anyway...
1

You can output a header to set it:

header('Content-type: text/html; charset=YOUR_CHARSET');

If you don't set a charset in this header, the browser will try to guess on its own which is not recommended. Most of the times in western countries that guess would be ISO-8859-1 or ISO-8859-15.

Comments

1
header('Content-Type: text/html'); // note the absence of charset=

Note however, that there's nothing such as "null charset", there's always some kind of mapping between the bytes and characters (even ASCII is such a mapping, not The Natural Order Of Things). What you're doing is telling the browser "I don't know what charset this is, just make a guess" - which may or may not choose the actual charset.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.