SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I make browser to recognize encoding of my xhtml pages?

    Hello everyone,

    I seem to have a little problem. Currently I'm working on localization of one web site from English to Serbian language. For Serbian I use windows-1250 charset (utf-8 can be used too). But I'm having problems displaying some specific characters in the browser. Here is how my header looks:
    Code:
    <?xml version="1.0" encoding="windows-1250"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sr" lang="sr">
        <head>
            <meta http-equiv="content-type" content="text/html; charset=windows-1250" />
    My files are saved as ascii in my code editor.
    The Strangest thing is that files are displayed properly when viewed locally on my hard drive, but as soon as I upload them on my server and try to view them in the browser (any browser), browser displays the page using standard ISO-8859-1 charset.

    How can I make browser to recognize encoding of my xhtml pages?

    Any ideas?

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It sounds to me like your server is sending a different HTTP header. You're going to have to either over-ride it with a server-side programming language like PHP or contact your hosting provider.

  3. #3
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Dan. This is the first time I have heard for such thing. I can't believe that hosting provider is doing that.

  4. #4
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, most of the time the typical hosting provider is going to use ISO-8859-1 or a similar character encoding. It's pretty typical, especially for sites that have a lot of content written in Western languages like English and French. I also think (don't quote me on this) that the server has it set to ISO-8859-1 by default anyway, so if I'm right, it wouldn't be your hosting provider's fault. Just ask them if they can switch the HTTP headers for your particular domain over to a compatible character encoding so you can properly serve your pages. If they have any competence and scruples whatsoever, they'll be more than happy to do so.

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Zagor
    For Serbian I use windows-1250 charset
    Quote Originally Posted by Zagor
    My files are saved as ascii in my code editor.
    If you want to use Windows-1250 for your XHTML document, you need to make sure of three things:
    1. The file must be saved as Windows-1250.
    2. The encoding attribute in the XML declaration should specify Windows-1250 (unless you're serving the document as text/html, in which case the XML declaration doesn't matter and you could use a meta element instead).
    3. The server must set the charset attribute to Windows-1250 in the Content-Type HTTP header, or omit it altoghether.


    See the Frequently Asked Questions about HTML for more information about character encodings.
    Birnam wood is come to Dunsinane

  6. #6
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thx Cuckoo!

    Forum administrators should really concentrate on search engine optimization for this forum, because info that I just read in that HTML FAQ is GOLD! I googled this issue for quite a bit of hours now and didn't stumbled at that page.


    Thank you again! All the best.

  7. #7
    SitePoint Wizard drhowarddrfine's Avatar
    Join Date
    Aug 2005
    Posts
    3,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are going to use a windows charset then are you ignoring all non-windows users? The modern way of doing things is to use utf-8 anyway so just use that.
    Also, the xml declaration won't work for IE6.
    IE does not understand xhtml served as xhtml, only modern browsers do.


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
  •