Sab*_*bya 7 php character-encoding
我使用PHP 5.2.6,我的应用程序的字符集是UTF-8.
现在,我应该如何更改PHP的默认字符集?不是指定输出的mime时间和字符集的那个.
但是对于所有PHP函数,例如htmlspecialchars,htmlentities等,这将改变.
我知道,这些函数中有一个参数,它接受输入字符串的字符集.但我不想指定我使用的所有功能.如果我忘记某个地方,那将是一团糟.
我也知道,我可以包装这些函数并创建我自己的包装器,如:
function myHtmlize($str)
{
return htmlspecialchars($str, ENT_COMPAT, 'UTF-8');
}
Run Code Online (Sandbox Code Playgroud)
我也是,不喜欢这个解决方案.
我真的想告诉PHP,默认情况下将'UTF-8'作为字符集.不是'iso-8859-1'.
可能吗?
像这个 ?https://www.php.net/manual/en/function.setlocale.php
* LC_ALL for all of the below
* LC_COLLATE for string comparison, see strcoll()
* LC_CTYPE for character classification and conversion, for example strtoupper()
* LC_MONETARY for localeconv()
* LC_NUMERIC for decimal separator (See also localeconv())
* LC_TIME for date and time formatting with strftime()
* LC_MESSAGES for system responses (available if PHP was compiled with libintl)
Run Code Online (Sandbox Code Playgroud)