开发者

Cakephp - "__" function give me question mark chars (�)

开发者 https://www.devze.com 2023-02-17 17:13 出处:网络
when I have <?php __(\'Écoutez votre grand-mère\'); ?> I have an output with question mark chars like: �coutez votre grand-m�re. Charset is set to utf-8 in my header. Wh开发者_StackOverflow中

when I have <?php __('Écoutez votre grand-mère'); ?> I have an output with question mark chars like: �coutez votre grand-m�re. Charset is set to utf-8 in my header. Wh开发者_StackOverflow中文版at's wrong ?

Cakephp - "__" function give me question mark chars (�)


This happened to a colleague a few days ago. He was using Eclipse and he was not saving the file as UTF-8.


Check the consistency of:

  • The encoding of the source file containing the message.
  • The encoding of the i18n message files, if any.
  • The content-encoding in the HTTP response header
  • The encoding specified in the HTML header
  • The encoding you browser chooses to render the page

Does it work if you do not use __() and just echo the message?


If you're saving your files as UTF-8 and still getting the same error, it might be a server issue. Add this line at the beginning of your app/config/bootstrap.php file:

header('Content-Type: text/html; charset=utf-8');

It's probably not the best solution, but it does the trick.

0

精彩评论

暂无评论...
验证码 换一张
取 消