在创建文件或重命名文件时使用Umlaute字符,它不能正确保存


While creating file or renaming file with Umlaute characters, it is not saving properly

创建新文件时只需键入Umlaute字符,即可正确保存。但在以其他方式创造时,它却不是。我在php尝试。我刚试过了

 $a = 'ä';
    alert($a,1); 
    echo $a;
and 

 file_put_contents("D:/ätest.txt","Hello");

显示一些奇怪的字符。所以尽快给我解决方案

基本上,您可能需要指定希望PHP使用UTF-8(或任何字符集)。

这个网站有很多关于PHP + UTF-8的信息:http://www.toptal.com/php/a-utf-8-primer-for-php-and-mysql

至少尝试在php.ini配置文件中设置default_charset = "utf-8";

您也可以尝试在写入文件之前专门对数据进行编码:

$fileName = utf8_encode("D:/ätest.txt");
$fileContent = utf8_encode("Hello");
file_put_contents($fileName, $fileContent);