Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,606
    Thanks
    6
    Thanked 997 Times in 970 Posts

    PHP character encoding issues

    OK, I have this site where some umlauts aren’t displayed correctly. Specifically those that aren’t directly written in the default HTML template but included through include files (Cake PHP’s THTML files in this case). I can encode some of the text with HTML entities but only the ones that are directly written in the HTML, not the ones that are written through PHP.

    Example:
    PHP Code:
            <?php echo $html->link(/*$comment['User']['username'].*/'Kommentar zum Geständnis machen''/messages/add/'.$comment['Comment']['user_id'].'/'.$comment['Comment']['id']); ?>
            <?php if($session->read('user.admin') == '1') { ?>
                <a href="<?php echo $html->url('/admin/comments/delete/'$comment['Comment']['id']); ?>">[L&ouml;schen</a>
    The ö in the word “Löschen” in the anchor (last line in example) would be displayed as “ö” if I put it literally but I can encode it as &ouml; (however, I’d rather write it out literally). However, the ä in the word “Geständnis” is echoed through PHP and I can’t put an HTML entity there because it would output it literally (as &auml;). I’ve come as far as figuring out that it must be the encoding of that THTML file (or the way PHP outputs characters) as plain HTML in the master template will be output correctly if I change the header’s charset.

    Unfortunately I’m not advanced enough in PHP to figure it out myself so how do I set/change the character encoding PHP is outputting? Or specifically how can I make it so I get proper characters from the PHP output rather than “ä” (that’s the output from the character “ä”) etc.?

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,606
    Thanks
    6
    Thanked 997 Times in 970 Posts
    I’m sad to see that nobody is responding… What else do you need from me, guys?

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,849
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Anything to do with meta charset?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,606
    Thanks
    6
    Thanked 997 Times in 970 Posts
    No, it’s not the meta charset in the HTML header. If I set that to UTF-8 the plain HTML umlauts are displayed wrong as well but if I set it to ISO-8859-1 they are alright. This has nothing to do with the HTML charset, it’s definitely the PHP character encoding since it’s only the characters that come from a PHP echo. That must be set from UTF-8 to ISO-8859-1, too, but I don’t know how and where. Any suggestions?


  •  

    Posting Permissions

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