PHP 和特殊字符

发布于 2024-10-01 01:13:09 字数 495 浏览 0 评论 0原文

我需要通过表单传输外来字符的帮助。 ü 和 é 等字符。我一直在阅读有关 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怎会甘心 2024-10-08 01:13:09

您需要告诉 PHP 在内存中存储字符串时使用某种内部编码。

mb_internal_encoding("UTF-8");
mb_http_output("UTF-8");
ob_start("mb_output_handler");

将此代码放在 PHP 代码的开头(我希望您有某种其他页面都包含的通用头文件)。

You need to tell PHP to use a certain internal encoding when it stores strings in memory.

mb_internal_encoding("UTF-8");
mb_http_output("UTF-8");
ob_start("mb_output_handler");

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).

一杯敬自由 2024-10-08 01:13:09

您不应该使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文