SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Mar 2004
    Posts
    260
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Special characters don't display with php include

    I'm using PHP inludes to include content on the page which stays the same, e.g.
    HTML Code:
    <?php include("_site-footer.php"); ?>
    My page have this tag in the head (also added with 'php include')
    HTML Code:
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    Special characters display fine if the text is directly on the page. However, if there is any included text the characters don't display, e.g.

    Vilkår comes out as Vilk�r, and so on.

    I have no idea what to do, so thank you for any help.

    P.S. My pages are in Norwegian with some English. Should I set the encoding to something different than UTF-8? Also, I only need to get it to work on my local machine for now – so no need to fiddle with settings on a hosting account. Just need to get it to work with PHP on my Mac.

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    If you load _site_footer.php DIRECTLY into your browser, are you saying it displays correctly?

    If that is the case the problems could be, as you imagined, the html encoding tag, you'd need to discover what the file itself is encoded as (some kind of iso_* perhaps?).

    What happens if you don't encode as utf-8?

    For me what generally works is this: In order to get your calling script and base include file using the exact same encoding then open them up in an IDE (NetBeans or similar) and reset the encoding. There are some text editors which will also do this for you (Vim).

    This is usually the case with language files that have come from somewhere else, or you have copy/pasted the text from somewhere else -- I find this a very common occurrence.

    These are wild stabs in the dark and if they don't do it for you then bone up on encoding by reading what this guy has to say kore nordman.

  3. #3
    SitePoint Addict
    Join Date
    Mar 2004
    Posts
    260
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply. I did get it to work by just pasting plain text into a new Dreamweaver file. Many thanks for your reply and encouraging me just to try.


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
  •