Charset not recognized

Discussion in 'HTML' started by Neal, Oct 25, 2004.

  1. Neal

    Neal Guest

    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?
     
    Neal, Oct 25, 2004
    #1
    1. Advertising

  2. Neal

    Philip Ronan Guest

    Neal wrote:

    > 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?

    --
    Philip Ronan

    (Please remove the "z"s if replying by email)
     
    Philip Ronan, Oct 25, 2004
    #2
    1. Advertising

  3. Neal

    Neal Guest

    On Mon, 25 Oct 2004 18:38:58 +0100, Philip Ronan
    <> wrote:

    > Neal wrote:
    >
    >> AddType 'text/html; charset=UTF-8' .php

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


    I've tried that, and no, results are the same.
     
    Neal, Oct 25, 2004
    #3
  4. Neal

    Neal Guest

    On Mon, 25 Oct 2004 13:23:23 -0400, Neal <> wrote:

    > 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.
     
    Neal, Oct 25, 2004
    #4
  5. *Neal* wrote:
    > 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
    --
    Andrew Urquhart
    - FAQ: http://www.html-faq.com/
    - Archive: http://groups.google.com/groups?group=alt.html
    - Reply: http://andrewu.co.uk/contact/
     
    Andrew Urquhart, Oct 25, 2004
    #5
  6. Neal

    Neal Guest

    On Mon, 25 Oct 2004 18:21:38 GMT, Andrew Urquhart
    <> wrote:

    > *Neal* wrote:
    >> 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...
     
    Neal, Oct 25, 2004
    #6
  7. Neal

    Neal Guest

    On Mon, 25 Oct 2004 18:21:38 GMT, Andrew Urquhart
    <> wrote:

    > *Neal* wrote:
    >> 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.
     
    Neal, Oct 25, 2004
    #7
  8. Neal wrote:
    > 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');
     
    Leif K-Brooks, Oct 25, 2004
    #8
  9. Neal

    Neal Guest

    On Mon, 25 Oct 2004 15:49:57 -0400, Leif K-Brooks <>
    wrote:

    > Neal wrote:
    >> 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');


    That did the trick.
     
    Neal, Oct 25, 2004
    #9
  10. *Neal* wrote:
    > On Mon, 25 Oct 2004 18:21:38 GMT, Andrew Urquhart
    > <> wrote:
    >
    >> *Neal* wrote:
    >>> 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:/
    --
    Andrew Urquhart
    - Reply: http://andrewu.co.uk/contact/
     
    Andrew Urquhart, Oct 25, 2004
    #10
  11. Neal

    Neal Guest

    On Mon, 25 Oct 2004 20:14:57 GMT, Andrew Urquhart
    <> wrote:

    > 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.
     
    Neal, Oct 25, 2004
    #11
  12. Neal

    brucie Guest

    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

    > The page in question is http://www.opro.org/new redesign/


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


    --


    v o i c e s
     
    brucie, Oct 25, 2004
    #12
  13. Neal

    Neal Guest

    On Tue, 26 Oct 2004 07:40:32 +1000, brucie <> wrote:

    > 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


    Unfortunately, I do not have access to the host's PHP settings. :(

    >> The page in question is http://www.opro.org/new redesign/

    >
    > <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.
     
    Neal, Oct 25, 2004
    #13
  14. Neal

    brucie Guest

    In alt.html Neal said:

    >> check the default charset php is sending and change it if needed.


    > Unfortunately, I do not have access to the host's PHP settings. :(


    you don't need it for charset:
    http://www.php.net/manual/en/function.ini-set.php

    --


    v o i c e s
     
    brucie, Oct 25, 2004
    #14
  15. Neal

    Neal Guest

    Neal, Oct 26, 2004
    #15
  16. Neal

    Neal Guest

    On Mon, 25 Oct 2004 19:14:11 -0400, Neal <> wrote:

    > On Tue, 26 Oct 2004 08:48:13 +1000, brucie <> wrote:
    >
    >> In alt.html Neal said:
    >>
    >>>> check the default charset php is sending and change it if needed.

    >>
    >>> Unfortunately, I do not have access to the host's PHP settings. :(

    >>
    >> you don't need it for charset:
    >> http://www.php.net/manual/en/function.ini-set.php

    >
    > Really new to this. I'm guessing frpm
    > http://www.php.net/manual/en/configuration.changes.php that I add to
    > .htaccess:
    >
    > php_value default_charset "UTF-8"
    >
    > Am I even close?


    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.
     
    Neal, Oct 26, 2004
    #16
  17. Neal

    Mark Parnell Guest

    On Mon, 25 Oct 2004 20:07:41 -0400, Neal <> declared in
    alt.html:

    >> Really new to this. I'm guessing frpm
    >> http://www.php.net/manual/en/configuration.changes.php that I add to
    >> .htaccess:
    >>
    >> php_value default_charset "UTF-8"

    > 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.

    --
    Mark Parnell
    http://www.clarkecomputers.com.au
    "Never drink rum&coke whilst reading usenet" - rf 2004
     
    Mark Parnell, Oct 26, 2004
    #17
  18. Neal

    Neal Guest

    On Tue, 26 Oct 2004 10:25:23 +1000, Mark Parnell
    <> wrote:
    > On Mon, 25 Oct 2004 20:07:41 -0400, Neal <> declared in
    > alt.html:
    >>> php_value default_charset "UTF-8"

    > 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.
     
    Neal, Oct 26, 2004
    #18
  19. Neal

    Mark Parnell Guest

    On Mon, 25 Oct 2004 20:51:58 -0400, Neal <> declared in
    alt.html:

    > 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.

    --
    Mark Parnell
    http://www.clarkecomputers.com.au
    "Never drink rum&coke whilst reading usenet" - rf 2004
     
    Mark Parnell, Oct 26, 2004
    #19
  20. Neal

    Neal Guest

    On Tue, 26 Oct 2004 11:34:56 +1000, Mark Parnell
    <> wrote:

    > On Mon, 25 Oct 2004 20:51:58 -0400, Neal <> declared in
    > alt.html:
    >
    >> 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.


    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.
     
    Neal, Oct 26, 2004
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pial
    Replies:
    6
    Views:
    52,519
    Nassos
    Apr 28, 2005
  2. S. Justin Gengo
    Replies:
    0
    Views:
    527
    S. Justin Gengo
    Aug 26, 2003
  3. =?Utf-8?B?TGVzdGVyIExlZQ==?=

    String was not recognized as a valid Boolean

    =?Utf-8?B?TGVzdGVyIExlZQ==?=, Jan 23, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    10,758
    Rajesh.V
    Feb 4, 2004
  4. SWATHI ALLU
    Replies:
    1
    Views:
    828
    Ken Cox [Microsoft MVP]
    Aug 22, 2004
  5. optimistx

    javascript charset <> page charset

    optimistx, Aug 14, 2008, in forum: Javascript
    Replies:
    2
    Views:
    304
    optimistx
    Aug 15, 2008
Loading...

Share This Page