Page 1 of 1
Text encoding
Posted: Mon Dec 28, 2009 8:54 pm
by rix501
I have an html page with special characters like "é" and "ñ" and they get displayed fine, but if I switch the extension to php, weird diamond question marks appear. I've done everything that I know of, I've set the charset to utf-8 everywhere, but still nothing works.
Any ideas?
Re: Text encoding
Posted: Mon Dec 28, 2009 9:33 pm
by requinix
And what is included in "everywhere"? It's pretty much (a) a call to PHP's header() function, or (b) a <meta> in the HTML page's <head>.
Re: Text encoding
Posted: Tue Dec 29, 2009 1:51 am
by Apollo
How did you include those characters in your php file? Did you(r editor) save it with utf-8 encoding?
Instead of including é and ñ literally, you're probably better off by using their html-entity equivalents: é ñ
Re: Text encoding
Posted: Tue Dec 29, 2009 9:32 am
by rix501
I saved it in th php.ini file, in the head (meta) and even in apache.
I don't know how the editor saved the file. Is that the problem?
Re: Text encoding
Posted: Tue Dec 29, 2009 10:35 am
by Apollo
rix501 wrote:I don't know how the editor saved the file. Is that the problem?
Yes. In your headers you say you are outputting UTF-8, but what you're actually outputting is whatever encoding your editor happens to use (cause that's what's saved in the .php file, so that's what PHP outputs).
There are all kinds of solutions to that, but simply using é and ñ and the likes is probably the best way to go.
Re: Text encoding
Posted: Tue Dec 29, 2009 5:51 pm
by rix501
Just checked it out and it was definitely the text editor saving the file in another encoding.
Thanks for the help!