且构网

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

检测PHP中的文件编码

更新时间:2023-02-26 13:35:32

尝试使用 mb_detect_encoding 函数.此函数将检查您的字符串并尝试猜测"其编码是什么.然后,您可以根据需要对其进行转换.但是,正如 brulak 建议的,您***转换to UTF-8 而不是 from,以保留您正在传输的数据.

Try using the mb_detect_encoding function. This function will examine your string and attempt to "guess" what its encoding is. You can then convert it as desired. As brulak suggested, however, you're probably better off converting to UTF-8 rather than from, to preserve the data you're transmitting.