且构网

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

PHP的Unicode问题

更新时间:2023-09-11 22:41:34

我正在使用win7 ntfs

I am using win7 ntfs

对不起,Windows下运行的PHP不支持包含通用Unicode字符的文件名.它只能处理完全由当前代码页中的字符组成的文件名.

Sorry, PHP running under Windows can't support filenames containing general Unicode characters. It can only cope with filenames made entirely of characters that lie within the current code page.

对于您来说,该代码页可能为1252(西欧,类似于ISO-8859-1),其中不包含西里尔字母.如果您在俄语安装上运行它,则您的代码页将为1251,并且西里尔字母字符可以工作-但带有重音符号的拉丁字母会损坏.

That code page is probably 1252 for you (Western European, similar to ISO-8859-1), which doesn't contain Cyrillic. If you run it on a Russian-language install then your code page would be 1251, and the Cyrillic characters would work - but accented Latin would break.

这是一个问题,影响到所有从MS C运行时使用标准C stdio库调用的应用程序,包括PHP,Java和其他应用程序. (某些语言,例如Python,使用Windows特定的API而非C stdlib来特别支持Unicode文件名;存在请求45517 使其进入PHP,但不要屏住呼吸.)

This is a problem that affects all applications that use the standard C stdio library calls from the MS C runtime, including PHP, Java and others. (Some languages, like Python, have special support for Unicode filenames using Windows-specific APIs instead of the C stdlib; there is Request 45517 to get the same into PHP but don't hold your breath.)

在非Windows平台上,倾向于通过使用具有UTF-8编码的字节字符串来支持Unicode,因此所有Unicode字符都可以使用.不幸的是,Windows没有此功能(代码页65001有点像UTF-8,但严重损坏).

On non-Windows platforms, Unicode tends to be supported by using byte strings with the UTF-8 encoding, and so all Unicode characters just work. Unfortunately Windows does not have this capability (code page 65001 is kind-of UTF-8, but badly broken).