php mkdir()在希伯来文创建gibrish文件夹 [英] php mkdir() in hebrew creates gibrish folder

查看:147
本文介绍了php mkdir()在希伯来文创建gibrish文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用英文版的php制作一个dir,它正在工作。
但是,当我尝试在希伯来语中,它创建像gibrish这样的文件夹:
'''''''| '''''''©''''〜

I am trying to make a dir using a php in english and it's working. But when i try in hebrew, it creats the folder in gibrish like so: ׳"׳•׳¨׳"׳"| ׳׳©׳—׳§ ׳©׳•׳׳˜

我该如何解决?
thanks

how can i fix it? thanks

推荐答案

PHP在处理字符串时有一些Unicode支持,但在内部PHP的字符串类型是单字节和不支持多字节编码。如果您将PHP文件保存为UTF-8格式,则可以使用正确的HTTP编码以UTF-8格式输出字符串,但许多PHP函数不支持多字节字符串。有些可以,但仍然不会。

PHP has some Unicode support when dealing with strings, but internally PHP's string type is single-byte and does not support multibyte encodings. If you save your PHP file in UTF-8 format, you can output strings in UTF-8 with the proper HTTP encodings, but many of PHP's functions don't support multi-byte strings. There are some that do, but still most that do not.

我在PHP源代码中查找了大部分文件系统函数,如 mkdir 不支持Unicode。它们对单字节字符串进行操作,这就是为什么当你尝试创建一个目录时你会得到ASCII乱码。

I looked around in the PHP source and most of the filesystem functions like mkdir are not Unicode aware. They operate on single byte strings which is why you get the ASCII gibberish when you try to create a directory.

你可以尝试调用 setlocale ,并在调用 mkdir 之前将它设置为 he_IL ,看看这是否有所不同。

You might try calling setlocale and setting it to he_IL before calling mkdir to see if this makes any difference.

更多信息:

For more information:


字符串是一系列字符,其中字符是与
字节相同。这意味着PHP仅支持256个字符的集合,因此
不提供本地Unicode支持。请参阅字符串类型的详细信息

有关不同编码的详细信息,可以根据是否使用Zend Multibyte支持在PHP中启用,以及如何将您的文件保存为不同的编码会影响PHP中的字符串。

The details talk more about different encodings, functions that are multi-byte aware and different behavior based on whether or not Zend Multibyte support is enabled in PHP and how saving your files in different encodings effects strings within PHP.

不幸的是,目前我不相信您能创建一个直接在PHP中包含多字节字符串。

Unfortunately at this time, I don't believe you will be able to create a directory containing multi-byte strings in PHP directly.

在内部,函数 mkdir 调用这个函数 mkdir in file.c ,它调用 _ php_stream_mkdir ,它使用纯文件包装器调用 php_mkdir_ex 最终用 virtual_mkdir ,它使用C mkdir函数创建目录。

Internally, the function mkdir calls this function mkdir in file.c which calls _php_stream_mkdir which uses the plain files wrapper to call php_mkdir_ex to ultimately create the directory using virtual_mkdir that uses the C mkdir function to create the directory.

我认为在调用mkdir创建目录时文件系统,所有的编码都已经丢失,并被视为一个单字节的char *字符串。

I think by the time it calls mkdir to create the directory on the file-system, all encodings have been lost and it is treated as a single-byte char * string.

这篇关于php mkdir()在希伯来文创建gibrish文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆