Charset not recognized

N

Neal

This is an HTTP issue more than an HTML issue, but perhaps someone has the
answer.

I'm beginning a redesign. I'm doing a site over using php. Rather than
include an http-equiv meta, I am using the .htaccess to specify the header.

I've set:

AddType 'text/html; charset=UTF-8' .php

in the .htaccess in my root. A similar statement for .html routinely sends
the proper encoding, in all directories.

However, the document.php pages do not seem to carry an encoding.

The page in question is http://www.opro.org/new redesign/ - still a work
in progress, not finished, but comments on its rendering and look are
welcome if you're so motivated.

But my main question: how do I get the headers to send UTF-8 for my .php
files?
 
P

Philip Ronan

Neal said:
I've set:

AddType 'text/html; charset=UTF-8' .php

in the .htaccess in my root. A similar statement for .html routinely sends
the proper encoding, in all directories.

However, the document.php pages do not seem to carry an encoding.

Try using double quote marks, and get rid of the "." in ".php"

Does that help?
 
N

Neal

I've set:

AddType 'text/html; charset=UTF-8' .php

in the .htaccess in my root. A similar statement for .html routinely
sends the proper encoding, in all directories.

Additional info:

I've also set .htaccess in the actual directory, with this exact content:

ErrorDocument 404 http://www.opro.org/error.html

AddCharset UTF-8 html php

AddType 'text/html; charset=UTF-8' html php

Still, no character encoding is sent. MIME type is sent correctly, but
that may be set on my host's end.

If I add

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

it sends UTF-8.
 
A

Andrew Urquhart

*Neal* said:
ErrorDocument 404 http://www.opro.org/error.html [snip]
Still, no character encoding is sent. MIME type is sent correctly, but
that may be set on my host's end.

Maybe you've changed something since you posted, but for the error
document URL above I see:

Content-Type: text/html; charset=utf-8

Although nothing still for the URL in the OP
 
N

Neal

*Neal* said:
ErrorDocument 404 http://www.opro.org/error.html [snip]
Still, no character encoding is sent. MIME type is sent correctly, but
that may be set on my host's end.

Maybe you've changed something since you posted, but for the error
document URL above I see:

Content-Type: text/html; charset=utf-8

Although nothing still for the URL in the OP

Yes, the html files are doing fine. Odd...
 
N

Neal

*Neal* said:
ErrorDocument 404 http://www.opro.org/error.html [snip]
Still, no character encoding is sent. MIME type is sent correctly, but
that may be set on my host's end.

Maybe you've changed something since you posted, but for the error
document URL above I see:

Content-Type: text/html; charset=utf-8

Although nothing still for the URL in the OP


This is an interesting development.

When I view the page in Firefox and look at page info, I get:

Encoding: ISO-8859-1

That's not set by me. Is Firefox falling back to this encoding, or could
my host be sending that in a way i cannot override?

At any rate, I have sent an email to my host concerning this.
 
L

Leif K-Brooks

Neal said:
I'm beginning a redesign. I'm doing a site over using php. Rather than
include an http-equiv meta, I am using the .htaccess to specify the header.

I've set:

AddType 'text/html; charset=UTF-8' .php

I could be wrong, but I think PHP sends a content-type header without
looking at Apache settings. Try adding this line to the top of your PHP
files (or put it in your main include file if you have one):

header('Content-Type: text/html; charset=UTF-8');
 
N

Neal

I could be wrong, but I think PHP sends a content-type header without
looking at Apache settings. Try adding this line to the top of your PHP
files (or put it in your main include file if you have one):

header('Content-Type: text/html; charset=UTF-8');

That did the trick.
 
A

Andrew Urquhart

*Neal* said:
*Neal* said:
ErrorDocument 404 http://www.opro.org/error.html [snip]
Still, no character encoding is sent. MIME type is sent correctly, but
that may be set on my host's end.

Maybe you've changed something since you posted, but for the error
document URL above I see:

Content-Type: text/html; charset=utf-8

Although nothing still for the URL in the OP

This is an interesting development.

When I view the page in Firefox and look at page info, I get:

Encoding: ISO-8859-1

That's not set by me. Is Firefox falling back to this encoding, or could
my host be sending that in a way i cannot override?

Opera's Info pages:

The error page:
Encoding from server (used by Opera):
utf-8 (utf-8)

The 'new design' page:
Encoding from server (used by Opera):
- not supplied - (windows-1252)

Confirmed by reading the raw headers via another app.

Gah - except since writing the above, the 'new design' page has started
returning UTF-8 in the headers :eek:/
 
N

Neal

Gah - except since writing the above, the 'new design' page has started
returning UTF-8 in the headers :eek:/

See my reply to Leif. PHP apparently makes the UA not refer to the HTTP
header. I supplied it in the php, that did it.
 
B

brucie

In alt.html Neal said:
AddType 'text/html; charset=UTF-8' .php
However, the document.php pages do not seem to carry an encoding.

check the default charset php is sending and change it if needed. host
probably has it as iso-8859-1.
http://www.php.net/manual/sv/configuration.directives.php#ini.default-charset

How to change configuration settings
http://www.php.net/manual/en/configuration.changes.php

<gasp/> a space! you should know better than that.
 
N

Neal

In alt.html Neal said:


check the default charset php is sending and change it if needed. host
probably has it as iso-8859-1.
http://www.php.net/manual/sv/configuration.directives.php#ini.default-charset

How to change configuration settings
http://www.php.net/manual/en/configuration.changes.php

Unfortunately, I do not have access to the host's PHP settings. :(
<gasp/> a space! you should know better than that.

Just a working directory, not going to be public (anymore than the link
appearing here will make it). Everything will move to the root when it's
done.
 
M

Mark Parnell

Apparently not close enough - that causes a 500 error when I try to access
a page. Funny - if I access a page where I've set the encoding in PHP on
the page, it works even with that line.

Looks right to me. What web server is your host running? If it's Apache,
that should work AFAICT. If it's Zeus, you can't do it - Zeus supports
..htaccess, but not the php_value option.
 
N

Neal

Looks right to me. What web server is your host running? If it's Apache,
that should work AFAICT. If it's Zeus, you can't do it - Zeus supports
.htaccess, but not the php_value option.

Apache. I just put that line in like that - should it be in any sort of
markup?

Use small words, I'm PHP stoopid.
 
M

Mark Parnell

Apache. I just put that line in like that - should it be in any sort of
markup?

No, just exactly as you have it there. Weird. I can't remember offhand,
but it may be a configuration option in Apache - you'd have to check
with your host. Maybe they have disabled php_value directives for some
reason.
 
N

Neal

No, just exactly as you have it there. Weird. I can't remember offhand,
but it may be a configuration option in Apache - you'd have to check
with your host. Maybe they have disabled php_value directives for some
reason.

I read something like that. I have an email into them, history says
they'll mail me back sometime tomorrow.

At any rate, setting it in php on top of the document works well enough.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top