Text editor: Always use UTF-8 to keep Ace happy.

This commit is contained in:
Tom Needham 2012-07-02 19:06:40 +00:00
parent 0a6f7b33c3
commit 88cbbc86b8
2 changed files with 2 additions and 0 deletions

View File

@ -43,6 +43,7 @@ if(!empty($filename))
{ {
$mtime = OC_Filesystem::filemtime($path); $mtime = OC_Filesystem::filemtime($path);
$filecontents = OC_Filesystem::file_get_contents($path); $filecontents = OC_Filesystem::file_get_contents($path);
$filecontents = iconv(mb_detect_encoding($filecontents), "UTF-8", $filecontents);
OCP\JSON::success(array('data' => array('filecontents' => $filecontents, 'write' => 'false', 'mtime' => $mtime))); OCP\JSON::success(array('data' => array('filecontents' => $filecontents, 'write' => 'false', 'mtime' => $mtime)));
} }
} else { } else {

View File

@ -48,6 +48,7 @@ if($path != '' && $mtime != '' && $filecontents)
// Save file // Save file
if(OC_Filesystem::is_writable($path)) if(OC_Filesystem::is_writable($path))
{ {
$filecontents = iconv(mb_detect_encoding($filecontents), "UTF-8", $filecontents);
OC_Filesystem::file_put_contents($path, $filecontents); OC_Filesystem::file_put_contents($path, $filecontents);
// Clear statcache // Clear statcache
clearstatcache(); clearstatcache();