且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP:将Unicode字符串转换为ANSI字符串

更新时间:2022-11-09 09:57:42

这不能正常工作.与Unicode存储在一起的字符比与ANSI存储的字符更多. 因此,如果您转换"为ANSI,则会失去很多特征.

This can't work properly. Stored with Unicode there are many more Characters than with ANSI. So if you "convert" to ANSI, you will loose lots of charackters.

http://php.net/manual/en/function.htmlentities.php

您可以将Unicode(UTF-8)字符集与htmlentities一起使用:

You can use Unicode (UTF-8) charset with htmlentities:

string htmlentities ( string $string [, int $flags = ENT_COMPAT [, string $charset [, bool $double_encode = true ]]] )

htmlentities($myString, ENT_COMPAT, "UTF-8");应该可以.