Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-09-2007, 11:29 PM   PM User | #1
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,614
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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.?
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 11-12-2007, 11:53 AM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,614
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
I’m sad to see that nobody is responding… What else do you need from me, guys?
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 11-12-2007, 12:05 PM   PM User | #3
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Anything to do with meta charset?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 11-12-2007, 01:18 PM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,614
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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?
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:13 AM.


Advertisement
Log in to turn off these ads.