473,386 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

[PHP4.1.2] Incorrect browser charset recognition

I have a problem with browser charset recognition when using PHP 4.1.2
(this is the PHP version which our hosting company provides).

For charset recognition, I use the following meta-tag:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Here is what I have tried so far:
- Regular html page: charset is properly recognised
- PHP page which just prints out the html: charset is not properly
recognised (ISO charset is chosen instead)
- ini_set("default_charset", "utf-8"): php_info() indicates that the
default charset has been set to utf-8, but still the regular ISO charset
is being used when the page is being displayed.
- Parsing the PHP page on my local PHP server (which is running 4.2.3):
Charset is properly recognised

The strange thing however is that it did work properly initially, but
about a month ago the problems with charset recognition started. The
PHP version of the provider has stayed the same, but maybe they have
changed some php settings (this is not very likely however).

Anyone has some advice for me?

Thanks in advance,
cj.

Jul 16 '05 #1
4 6172
I had to write XML with the UTF-8 characterset for interaction with a Flash
movie. To accomplish this I had to ask my hosting provider to activate the
mbstring functions in PHP. Would be worth to compare your local and remote
server on this point. In the PHP manual it says:

--enable-mbstring : Enable mbstring functions. This option is required to
use mbstring functions.
--enable-mbstr-enc-trans : Enable HTTP input character encoding conversion
using mbstring conversion engine. If this feature is enabled, HTTP input
character encoding may be converted to mbstring.internal_encoding
automatically.
I don't know how default_charset relates to mb_internal_encoding("UTF-8");
May be you will need that as well.

When your internal encoding is different, like it was in my case (all my
data was in another character set), you will need:

mb_http_output("UTF-8");
ob_start("mb_output_handler");

This will output UTF-8 character set while input and internally works with
another character set.

All this won't work when the mbstring functions are not activated before.

I hope this has helped you somehow.

René
Jul 16 '05 #2
Both the hosting and my local server do not have the mbstring functions
enabled, so I doubt that my problems are related to this. What happens
is that the browser just does not set encoding to "UTF-8". I requested
two documents, one called test.htm and the other one test.php. They
both contained the same html text (no php scripting): just a meta tag
which sets the content type to "UTF-8". The document with the html
extension worked flawlessly, the php document did not. I find this
particularly strange.

Anyway, big thanks for trying to help me, it is very much appreciated!
no****@nodomain.com wrote:
I had to write XML with the UTF-8 characterset for interaction with a Flash
movie. To accomplish this I had to ask my hosting provider to activate the
mbstring functions in PHP. Would be worth to compare your local and remote
server on this point. In the PHP manual it says:

--enable-mbstring : Enable mbstring functions. This option is required to
use mbstring functions.
--enable-mbstr-enc-trans : Enable HTTP input character encoding conversion
using mbstring conversion engine. If this feature is enabled, HTTP input
character encoding may be converted to mbstring.internal_encoding
automatically.
I don't know how default_charset relates to mb_internal_encoding("UTF-8");
May be you will need that as well.

When your internal encoding is different, like it was in my case (all my
data was in another character set), you will need:

mb_http_output("UTF-8");
ob_start("mb_output_handler");

This will output UTF-8 character set while input and internally works with
another character set.

All this won't work when the mbstring functions are not activated before.

I hope this has helped you somehow.

René


Jul 16 '05 #3
Hmmm, if I save my document as UTF-8 (instead of ASCII), the browser
sets the Charset to UTF-8 but I cannot use sessions anymore since the
header has already been sent (apparently PHP does not ignore the UTF-8 BOM).

Anyone knows a work-around? I just need to be able to set the browser
to UTF-8, the PHP file can be in ASCII, no problem. But whenever the
PHP parser is used, the html meta tag just seems to be ignored.

Maybe the mbstring functions can indeed offer a solution, although I do
not have them enabled on my home 4.2.3 server where everything works fine.
CJ Oxx wrote:
Both the hosting and my local server do not have the mbstring functions
enabled, so I doubt that my problems are related to this. What happens
is that the browser just does not set encoding to "UTF-8". I requested
two documents, one called test.htm and the other one test.php. They
both contained the same html text (no php scripting): just a meta tag
which sets the content type to "UTF-8". The document with the html
extension worked flawlessly, the php document did not. I find this
particularly strange.

Anyway, big thanks for trying to help me, it is very much appreciated!
no****@nodomain.com wrote:
I had to write XML with the UTF-8 characterset for interaction with a
Flash
movie. To accomplish this I had to ask my hosting provider to activate
the
mbstring functions in PHP. Would be worth to compare your local and
remote
server on this point. In the PHP manual it says:

--enable-mbstring : Enable mbstring functions. This option is required to
use mbstring functions.
--enable-mbstr-enc-trans : Enable HTTP input character encoding
conversion
using mbstring conversion engine. If this feature is enabled, HTTP input
character encoding may be converted to mbstring.internal_encoding
automatically.
I don't know how default_charset relates to
mb_internal_encoding("UTF-8");
May be you will need that as well.

When your internal encoding is different, like it was in my case (all my
data was in another character set), you will need:

mb_http_output("UTF-8");
ob_start("mb_output_handler");

This will output UTF-8 character set while input and internally works
with
another character set.

All this won't work when the mbstring functions are not activated before.

I hope this has helped you somehow.

René


Jul 16 '05 #4
Hello René,

I did some more testing and the mbstring seem to be able to provide a
solution :) On my test server, the UTF meta tag works, but when I set
the meta tag to ISO, enable the mbstring functions and use
mb_http_output("UTF-8"), the browser detects UTF-8 and ignores the meta
tag settings. So this is great news! I have contacted the provider and
requested to enable the mbstring functions.

Thank you very much for your help,
cj.
no****@nodomain.com wrote:
I had to write XML with the UTF-8 characterset for interaction with a Flash
movie. To accomplish this I had to ask my hosting provider to activate the
mbstring functions in PHP. Would be worth to compare your local and remote
server on this point. In the PHP manual it says:

--enable-mbstring : Enable mbstring functions. This option is required to
use mbstring functions.
--enable-mbstr-enc-trans : Enable HTTP input character encoding conversion
using mbstring conversion engine. If this feature is enabled, HTTP input
character encoding may be converted to mbstring.internal_encoding
automatically.
I don't know how default_charset relates to mb_internal_encoding("UTF-8");
May be you will need that as well.

When your internal encoding is different, like it was in my case (all my
data was in another character set), you will need:

mb_http_output("UTF-8");
ob_start("mb_output_handler");

This will output UTF-8 character set while input and internally works with
another character set.

All this won't work when the mbstring functions are not activated before.

I hope this has helped you somehow.

René


Jul 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: darren.brierton | last post by:
Hi! We've been building a pretty big web app here for internal use. SMS text messages come in from an aggregator and are stored in a MySQL 4 db. Our operators then deal with them using a web...
0
by: Oleg Medyanik | last post by:
Hello, All I've a problem with browser type recognition. I have framework 1.0 SP2 installed I can easily determine IE and it's versioin, Netscape 6.1 But Netscape 7.x and Mozilla 1.4 are...
6
by: Dario Di Bella | last post by:
Hi all, I hope someone can help me on this. I need to parse the following XML: .... <area name="promotore"> <item id="004" code="003" description="attivita promotore"> <!]> </item> </area>...
0
by: FrankL | last post by:
I had to update my server configuration consisting of Apache2 and PHP4. I now have installed: apache2/apache2-prefork 2.0.54-2.1 apache-mod_php4/php4-zlib/php4 4.3.11-0.3.1 ...
1
by: news8080 | last post by:
I downloaded a GUI for nagios that uses PHP but when I point the browser at the PHP file, it shows me the source of .php file instead of executing it, if i use command line 'php filname.php'...
0
by: Pixie | last post by:
We are successfully getting a handle to a drive using createfile then using that handle to query the change journal using DeviceIOControl with the paramter FSCTL_QUERY_USN_DATA. However when we try...
2
by: Effie | last post by:
Hi! Is there a way to detect if the "Auto-select" is been checked on the user's browser? TIA, Effie
6
by: Leon_Amirreza | last post by:
My Page contains this: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> i used this code to retrieve the page: HttpWebResponse webresp =...
14
by: Jeff | last post by:
I'm working on a server that is running PHP4. I'd like to upgrade this so I can use the PHP5 code I have already. What kind, if any, problems will I have with the existing PHP code base? I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.