Utf 8 Yii2 FileHelper::findFiles()-非ASCII字符错误

Utf 8 Yii2 FileHelper::findFiles()-非ASCII字符错误,utf-8,character-encoding,internationalization,yii2,yii2-advanced-app,Utf 8,Character Encoding,Internationalization,Yii2,Yii2 Advanced App,我正在从yii2高级应用程序开发一个应用程序 在控制器(DocumentController)中,我用FileHelper::findFiles()读取目录中的文件 它可以工作,但如果我的文件名包含非ASCII字符(如德语umlauts,äöü),我只会在返回的文件路径中得到一个问号 我如何解决这个问题?我找不到合适的答案 作为web服务器,我在R2企业上使用IIS7 DocumentController.php use yii\helpers\FileHelper; $data = File

我正在从yii2高级应用程序开发一个应用程序

在控制器(DocumentController)中,我用FileHelper::findFiles()读取目录中的文件

它可以工作,但如果我的文件名包含非ASCII字符(如德语umlauts,äöü),我只会在返回的文件路径中得到一个问号

我如何解决这个问题?我找不到合适的答案

作为web服务器,我在R2企业上使用IIS7

DocumentController.php

use yii\helpers\FileHelper;

$data = FileHelper::findFiles($folderPath,['except'=>['*.db']]);

var_dump($data);
结果是:

array(1) { [0]=> string(84) "C:\Websites\dev.point-s.de\space/space_attachments/10082\Aushang 201501 Gr�ndung.pdf" }

输出应该使用以下代码完成,但我认为问题在于文件的读取

Html::a($model['name'], ['document/download', 'file' => $model['name']])

好的,谢谢@ineersa的帮助,我在同事的帮助下得到了答案

解决方案是使用PHP函数将findFiles()返回的文件名显式转换为UTF-8


var\u dump
不使用任何编码。在转储之前设置utf-8
头文件。请解释到底是什么不起作用。我的目录中有文件,应该列在列表中(
  • Html::a($filename,['document/download',file'=>$model['name']])
  • utf-8
?因为这是yii中的默认选项,所以我的页面源代码显示了行