To fix Chinese character display abnormal

When "default_charset" was not set in php.ini,and the file contents chinese char,it may show incorrectly.
Because the function htmlentities() takes "ISO-8859-1" as default value of "default_charset"  if PHP version is lower than 5.4.
So I think it's better to check the "default_charset" before function htmlentities().
What's your opinion?
This commit is contained in:
bhz6344
2015-08-17 14:23:45 +08:00
parent 7540ef846f
commit ac65cd89c1

View File

@@ -103,7 +103,10 @@ if ($_GET['action']=="load") {
} else {
$loadedFile = toUTF8noBOM(file_get_contents($file,false,$context),true);
}
echo '</script><textarea name="loadedFile" id="loadedFile">'.htmlentities($loadedFile).'</textarea><script>';
$encoding=ini_get("default_charset");
if($encoding=="")
$encoding="UTF-8";
echo '</script><textarea name="loadedFile" id="loadedFile">'.htmlentities($loadedFile,ENT_COMPAT,$encoding).'</textarea><script>';
// Run our custom processes
include_once("../processes/on-file-load.php");
} else if (strpos($finfo,"image")===0) {
@@ -218,4 +221,4 @@ if (action=="load") {
// Finally, switch mode in case we have saved, renamed file etc
top.ICEcoder.switchMode();
</script>
</script>