Professional Web Applications Themes

[PHP4.1.2] Incorrect browser charset recognition - PHP Development

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

  1. #1

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

    CJ Oxx Guest

  2. #2

    Default [PHP4.1.2] Incorrect browser charset recognition

    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é


    Guest

  3. #3

    Default Re: [PHP4.1.2] Incorrect browser charset recognition

    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!


    [email]nospam@nodomain.com[/email] 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é
    >
    >
    CJ Oxx Guest

  4. #4

    Default Re: [PHP4.1.2] Incorrect browser charset recognition

    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!
    >
    >
    > [email]nospam@nodomain.com[/email] 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é
    >>
    >>
    >
    CJ Oxx Guest

  5. #5

    Default Re: [PHP4.1.2] Incorrect browser charset recognition

    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.


    [email]nospam@nodomain.com[/email] 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é
    >
    >
    CJ Oxx Guest

Similar Threads

  1. OCR Text Recognition From C#
    By Tom_Allen@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 3
    Last Post: January 6th, 11:16 AM
  2. #39103 [NEW]: Oracle CLOB Charset Incorrect
    By jhtpeter at gmail dot com in forum PHP Bugs
    Replies: 6
    Last Post: October 26th, 04:58 PM
  3. #39103 [Opn]: Oracle CLOB Charset Incorrect
    By jhtpeter at gmail dot com in forum PHP Bugs
    Replies: 0
    Last Post: October 10th, 02:18 AM
  4. Voice recognition
    By Urme webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 1
    Last Post: November 6th, 09:32 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139