PHP中的编码问题(UTF-8) [英] Encoding problem (UTF-8) in PHP

查看:118
本文介绍了PHP中的编码问题(UTF-8)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在PHP中输出以下字符串:



äöü߀



因此,我已经将其编码为utf8手动:



ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÂ是:

 <?php 
header('content-type:text / html; charset = utf-8 );
echo'ÃÃÃÃÃÃÂÂ
?>

前4个字符是正确的(äöüß),但不幸的是,€符号不正确:



äöüß



这里你可以看到它。



你能告诉我我做错了什么吗?我的编辑器(Notepad ++)有编码(Ansi / UTF-8)和格式(Windows / Unix)的设置。我必须改变他们吗?



希望你能帮助我。感谢提前!

解决方案

最后一个字符只是不在文件中(尝试查看源代码),这就是为什么你没有看到它。



我认为您可能会更好地将PHP文件保存为UTF-8(在Notepad ++中,该选项在格式 - > Encode in UTF中可用-8没有BOM),并将实际的字符插入您的PHP文件(即在记事本++中),而不是在任何地方插入Ã。您可能会发现Windows Character Map可用于插入unicode字符。


I want to output the following string in PHP:

ä ö ü ß €

Therefore, I've encoded it to utf8 manually:

ä ö ü ß €

So my script is:

<?php
header('content-type: text/html; charset=utf-8');
echo 'ä ö ü ß €';
?>

The first 4 characters are correct (ä ö ü ß) but unfortunately the € sign isn't correct:

ä ö ü ß

Here you can see it.

Can you tell me what I've done wrong? My editor (Notepad++) has settings for Encoding (Ansi/UTF-8) and Format (Windows/Unix). Do I have to change them?

I hope you can help me. Thanks in advance!

解决方案

That last character just isn't in the file (try viewing the source), which is why you don't see it.

I think you might be better off saving the PHP file as UTF-8 (in Notepad++ that options is available in Format -> Encode in UTF-8 without BOM), and inserting the actual characters in your PHP file (i.e. in Notepad++), rather than hacking around with inserting à everywhere. You may find Windows Character Map useful for inserting unicode characters.

这篇关于PHP中的编码问题(UTF-8)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆