Skip to content

Fix Lfm::translateFromUtf8() to handle an array of strings and not only a string. #1260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/Lfm.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,21 @@ public function allowShareFolder()
}

/**
* Translate file name to make it compatible on Windows.
* Translate file or directory name(s) to be compatible on Windows.
*
* @param string $input Any string.
* @return string
* @param string|array $input Any string or array of strings.
* @return string|array
*/
public function translateFromUtf8($input)
{
if ($this->isRunningOnWindows()) {
$input = iconv('UTF-8', mb_detect_encoding($input), $input);
if (is_array($input)) {
foreach ($input as &$item) {
$item = iconv('UTF-8', mb_detect_encoding($item), $item);
}
} else {
$input = iconv('UTF-8', mb_detect_encoding($input), $input);
}
}

return $input;
Expand Down