Hi, I wrote the same mail some days ago in the general list and I asked also
on the #php IRC channel on Freenode but I didn't find any answer, so I try
here.
I need to set the default charset for my application to UTF-8 instead of
the default one of the webserver that is ISO-8859-1.
I've tried to change the value of default_charset in php.ini and all it's ok,
but I need to set the value only for one application so I've tried to use the
ini_set function in this way:
ini_set('default_charset','utf-8');
The problem is that that the ini_set function seems to be ignored, I don't
have the same effect of changing the php.ini configuration file, with the
ini_set function the default charset of the output is still ISO-8859-1.
My system: PHP 5.0.5, Apache 2.0.54.
Someone can help me?
Regards.
Graziano 'FreeJay' Liberati
Main developer of ZNF http://znf.zeronotice.com
Contacts
web: http://www.freejay.it
e-mail: freejay@freejay.it
icq: 98659824
msn: freejay@freejay.it
Not really a question for internals.
header("Content-type: text/html; charset=UTF-8");
from your application will do the trick.
-Rasmus
Graziano Liberati wrote:
Hi, I wrote the same mail some days ago in the general list and I asked also
on the #php IRC channel on Freenode but I didn't find any answer, so I try
here.I need to set the default charset for my application to UTF-8 instead of
the default one of the webserver that is ISO-8859-1.
I've tried to change the value of default_charset in php.ini and all it's ok,
but I need to set the value only for one application so I've tried to use the
ini_set function in this way:
ini_set('default_charset','utf-8');The problem is that that the ini_set function seems to be ignored, I don't
have the same effect of changing the php.ini configuration file, with the
ini_set function the default charset of the output is still ISO-8859-1.My system: PHP 5.0.5, Apache 2.0.54.
Someone can help me?
Regards.
At Wednesday 4 January 2006 11:40, Rasmus Lerdorf you wrote:
Not really a question for internals.
header("Content-type: text/html; charset=UTF-8");
from your application will do the trick.
-Rasmus
In this way I set also the text/html content type, but I don't know prior the
execution if I have an html, pdf or whatever, I want to set only the charset.
Regards.
Graziano 'FreeJay' Liberati
Main developer of ZNF http://znf.zeronotice.com
Contacts
web: http://www.freejay.it
e-mail: freejay@freejay.it
icq: 98659824
msn: freejay@freejay.it
Hi Graziano,
At 10:42 04.01.2006, you wrote:
I need to set the default charset for my application to UTF-8 instead of
the default one of the webserver that is ISO-8859-1.
I've tried to change the value of default_charset in php.ini and all it's ok,
but I need to set the value only for one application so I've tried to use the
ini_set function in this way:
ini_set('default_charset','utf-8');The problem is that that the ini_set function seems to be ignored, I don't
have the same effect of changing the php.ini configuration file, with the
ini_set function the default charset of the output is still ISO-8859-1.
create a .htaccess file in the application directory where you use
the "php_value" command to set this variable. See http://www.php.net/php_value
The problem is that changing the charset in the script is too late
(it is running so it cannot be changed anymore).
Uwe Schindler
thetaphi@php.net - http://www.php.net
NSAPI SAPI developer
Bremen, Germany
At Wednesday 4 January 2006 11:45, Uwe Schindler you wrote:
create a .htaccess file in the application directory where you use
the "php_value" command to set this variable. See
http://www.php.net/php_valueThe problem is that changing the charset in the script is too late
(it is running so it cannot be changed anymore).
Why it's too late? The content type (so also the charset) is not setted until
the first instruction of output, for example I can use (as said by Rasmus)
header("Content-type: text/html; charset=UTF-8");
From the manual:
" Remember that header()
must be called before any actual output is sent,
either by normal HTML tags, blank lines in a file, or from PHP. It is a very
common error to read code with include(), or require(), functions, or another
file access function, and have spaces or empty lines that are output before
header()
is called. The same problem exists when using a single PHP/HTML
file."
Regards.
Graziano 'FreeJay' Liberati
Main developer of ZNF http://znf.zeronotice.com
Contacts
web: http://www.freejay.it
e-mail: freejay@freejay.it
icq: 98659824
msn: freejay@freejay.it
PHP had a bug when handling the default_charset in CGI mode.
Upgrading PHP will do the trick.
Nuno
Hi, I wrote the same mail some days ago in the general list and I asked
also
on the #php IRC channel on Freenode but I didn't find any answer, so I try
here.I need to set the default charset for my application to UTF-8 instead of
the default one of the webserver that is ISO-8859-1.
I've tried to change the value of default_charset in php.ini and all it's
ok,
but I need to set the value only for one application so I've tried to use
the
ini_set function in this way:
ini_set('default_charset','utf-8');The problem is that that the ini_set function seems to be ignored, I don't
have the same effect of changing the php.ini configuration file, with the
ini_set function the default charset of the output is still ISO-8859-1.My system: PHP 5.0.5, Apache 2.0.54.
Someone can help me?
Regards.