php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11951 HTML encoding problem
Submitted: 2001-07-07 18:18 UTC Modified: 2001-08-06 09:27 UTC
From: bogo at cyberdude dot com Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 4.0.5 OS: Any
Private report: No CVE-ID: None
 [2001-07-07 18:18 UTC] bogo at cyberdude dot com
There definately seems to be a problem using any operating system I've tried (Linux Debian, RedHat, Windows 98, Windows 2000). The problem is that the following piece of HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" CONTENT="text/html; charset=windows-1251">
.......

will somehow be ignored, i.e. the document will not have this encoding set, instead ISO-8859-1 will be used. The biggest problem is that if try to change the encoding in the browser it won't change it, even though the browser will show it changed or if it changes it (very rare), after you reload the page the encoding is set back to ISO-8859-1, even though the browser always shows that the encoding is changed. This happens for all files that are processed by the php engine. I've correctly set the encoding option in the php.ini, even though it is always best for php, not to set this at all, since if you're using a remote server, for example hosting you site in the USA, but the page is in cyrillic, your php pages will never display properly. Probably the best thing is to leave the encoding up to the HTML headers set by each page.

My workaround for this problem is (it always works correctly):
<?
  include "set_encoding.inc";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" CONTENT="text/html; charset=windows-1251">
........

where set_encoding.inc, contains in my case the following:
  header("Content-type: text/html;charset=windows-1251");
  header("Content-Language: bg");


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-07 19:52 UTC] joey@php.net
Have you checked the default_charset in your php.ini?
 [2001-08-06 09:27 UTC] andy@php.net
no feedback
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 10:01:31 2024 UTC