diff --git a/lib/file-control.php b/lib/file-control.php
index 2fe3170..98d8542 100644
--- a/lib/file-control.php
+++ b/lib/file-control.php
@@ -1,4 +1,4 @@
-
+
fileType="text";';
echo 'top.ICEcoder.shortURL = top.ICEcoder.rightClickedFile = top.ICEcoder.thisFileFolderLink = "'.$fileLoc."/".$fileName.'";';
echo '';
- $loadedFile = file_get_contents($file);
+ $loadedFile = toUTF8noBOM(file_get_contents($file),true);
echo '","",str_replace("&","&",$loadedFile)).'';
} else if (strpos($finfo,"image")===0) {
echo '';
@@ -53,7 +53,7 @@ if ($_GET['action']=="load") {
// Get the contents of a remote URL
if ($_GET['action']=="getRemoteFile") {
- if ($remoteFile = file_get_contents($file)) {
+ if ($remoteFile = toUTF8noBOM(file_get_contents($file),true)) {
// replace \r\n (Windows), \r (old Mac) and \n (Linux) line endings with whatever we chose to be lineEnding
$remoteFile = str_replace("\r\n", $ICEcoder["lineEnding"], $remoteFile);
$remoteFile = str_replace("\r", $ICEcoder["lineEnding"], $remoteFile);
@@ -197,7 +197,7 @@ if ($_GET['action']=="rename") {
if ($_GET['action']=="replaceText") {
if (!$demoMode && is_writable(str_replace("|","/",strClean($_GET['fileRef'])))) {
$file = str_replace("|","/",strClean($_GET['fileRef']));
- $loadedFile = file_get_contents($file);
+ $loadedFile = toUTF8noBOM(file_get_contents($file),true);
$newContent = str_replace(strClean($_GET['find']),strClean($_GET['replace']),$loadedFile);
$fh = fopen($file, 'w') or die("Sorry, cannot save");
fwrite($fh, $newContent);
@@ -290,7 +290,7 @@ if ($_GET['action']=="save") {
// Reload previewWindow window if not a Markdown file
echo '';
} else {
- $loadedFile = file_get_contents($file);
+ $loadedFile = toUTF8noBOM(file_get_contents($file),true);
echo '","",htmlentities($loadedFile)).'';
echo '';
?>