开发者

PHP and special characters

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 = 开发者_如何学Python'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.


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


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜