UTF-8 without BOM questions and saving files

Discussion in 'HTML & Website Design' started by pipes, Jul 28, 2008.

  1. #1
    If i have been creating and saving pages as UTF-8 without BOM, then open up a CSS file connected to it all, forget what i was doing and save it in notepad by mistake (as UTF-8 only) would this make the CSS file cause any problems?

    Does it matter that a CSS file is saved that way or would it only apply to the .php pages that im working with?

    My reason for asking, no probs while i leave my index file as a whole (WP Theme) but once i try and move the sidebar code into their own files i get problems with the layout that is only corrected by placing the sidebar text back into the index.php file.
     
    pipes, Jul 28, 2008 IP
  2. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #2
    AFAIR BOM at the file beginning should be parsed properly (IE - 100% :)), but if your page composed from several chunks (i.e. header.tpl, footer.tpl, etc.) and these files contain BOM mark - you can run into unexpected problems. These characters can be displayed by some browsers or broke page layout. I would recommend to resave them without BOM signature (using Notepad2 for example).
     
    wmtips, Jul 28, 2008 IP
    pipes likes this.
  3. pipes

    pipes Prominent Member

    Messages:
    12,766
    Likes Received:
    958
    Best Answers:
    0
    Trophy Points:
    360
    #3
    Thanks wmtips il resave each of the files as you suggest and thanks very much for the link too.
     
    pipes, Jul 29, 2008 IP
  4. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well, since UTF-8 doesn't actually need the BOM, that could explain why someone doesn't parse it correctly. UTF-16 does need it, but who's using that? : )
     
    Stomme poes, Jul 29, 2008 IP
  5. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #5
    BOM commonly used by Microsoft software. For example, in MS Notepad you can save text file in ANSI or unicode encoding, and when opened, its encoding will be determined using BOM:
    if BOM exists then unicode
    else ANSI
    Code (markup):
    If BOM is stripped, you have to manually specify an encoding for the viewer.
     
    wmtips, Jul 29, 2008 IP
  6. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #6
    For other applications that may be usefull... now I don't use MS products but I'd think for just websites (HTML documents) we can dispense with the BOM... with other documents, things may be different.

    Not necessarily a bad thing, as apparently while UTF-8 is supposed to be like a default of there's not HTTPHeader telling the browser which charset to use, plenty of Windows machines (like mine at work apparently) like to default to that Windows 1250 instead (which, with Dutch, makes ??? in place of letters... not sure why though as all our letters are part of the 1250 I thought). So, likely a good thing that it should be in the HTTP Header, the meta tag, and how the document was saved all at the same time.
     
    Stomme poes, Jul 30, 2008 IP