mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
Add encoding change function
This commit is contained in:
parent
1e023a1247
commit
cdfb8894b9
|
|
@ -117,4 +117,23 @@ final class FileUtils
|
|||
|
||||
return \realpath($origPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change encoding of file
|
||||
*
|
||||
* @param string $file Path to file which should be re-encoded
|
||||
* @param string $encoding New file encoding
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function changeFileEncoding(string $file, string $encoding) : void
|
||||
{
|
||||
$content = \file_get_contents($file);
|
||||
|
||||
if ($content !== false && preg_match('!!u', $content)) {
|
||||
\file_put_contents($file, \mb_convert_encoding($content, 'UTF-8', mb_list_encodings()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user