PHP 和特殊字符
我需要通过表单传输外来字符的帮助。 ü 和 é 等字符。我一直在阅读有关 mb_language 和 mb_convert_encoding 的文档,并且可以让它适用于日语字符,但不适用于欧洲字符。德语似乎没有 mb_language('de'),而日语则有 mb_language('ja')。
我正在尝试这个,但它不起作用:
$subjectAutoresponder = 'Vielen Dank für Ihre Kontaktaufnahme';
$subjectAutoresponder = mb_convert_encoding($subjectAutoresponder, "ISO-8859-1", "UTF-8");
$subjectAutoresponder = mb_encode_mimeheader($subjectAutoresponder);
有人可以帮助我吗?在标题中,它消除了 ü 而不是对其进行转换。另外,我需要做什么才能获得提交外文字符的表格。谢谢。
I need help with transmitting foreign characters via forms. Characters like ü and é. I have been reading the documentation on mb_language and mb_convert_encoding, and can get it to work for Japanese characters, but not for European characters. There seems to be no mb_language('de') for German as there is mb_language('ja') for Japansese.
I am trying this, but it doesn't work:
$subjectAutoresponder = 'Vielen Dank für Ihre Kontaktaufnahme';
$subjectAutoresponder = mb_convert_encoding($subjectAutoresponder, "ISO-8859-1", "UTF-8");
$subjectAutoresponder = mb_encode_mimeheader($subjectAutoresponder);
Can someone help me? In the header, it eliminates the ü rather than converting it. Also, what do I need to do to get a form to submit foreign characters. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要告诉 PHP 在内存中存储字符串时使用某种内部编码。
将此代码放在 PHP 代码的开头(我希望您有某种其他页面都包含的通用头文件)。
You need to tell PHP to use a certain internal encoding when it stores strings in memory.
Put this code at the start of your PHP code (I'm hoping you have some sort of common header file that every other page includes).
您不应该使用 ISO-8859-1。尝试使用 UTF-8 编码所有内容。它处理了我能想到的几乎所有角色。您不需要手动编码任何内容。
You should not be using ISO-8859-1. Try encoding everything with UTF-8. It handles quite every character i can think of. You do not need to encode anything manually.