473,378 Members | 1,478 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,378 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 6170
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.