且构网

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

在PHP中检测文件编码

更新时间:2023-02-26 13:52:45

尝试使用 mb_detect_encoding 函数。这个函数将检查你的字符串,并试图猜它的编码是什么。然后,您可以根据需要进行转换。不过,如果 brulak建议,您***将 UTF-8,而不是 ,以保留您要传输的数据。

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.