From fd5ca378e69a49b3f2a5f797c7c5f8606ed6b36d Mon Sep 17 00:00:00 2001 From: skodak Date: Fri, 3 Mar 2006 22:22:07 +0000 Subject: [PATCH] fixed UTF-8 restore problems caused by utf8_restore --- backup/lib.php | 8 ++++++-- backup/restorelib.php | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backup/lib.php b/backup/lib.php index c3ffeeecdcc..88f788159c5 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -470,10 +470,14 @@ return $status; } - //This function is used to add slashes and decode from UTF-8 + //This function is used to add slashes (and decode from UTF-8 if needed) //It's used intensivelly when restoring modules and saving them in db function backup_todb ($data) { - return restore_decode_absolute_links(addslashes(utf8_decode($data))); + if (current_charset() != 'UTF-8') { + return restore_decode_absolute_links(addslashes(utf8_decode($data))); + } else { + return restore_decode_absolute_links(addslashes($data)); + } } //This function is used to check that every necessary function to diff --git a/backup/restorelib.php b/backup/restorelib.php index 5373647a421..7677db0dd8d 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2918,9 +2918,13 @@ var $finished = false; //Flag to say xml_parse to stop //This function is used to get the current contents property value - //They are trimed and converted from utf8 + //They are trimed (and converted from utf8 if needed) function getContents() { - return trim(utf8_decode($this->content)); + if (current_charset() != 'UTF-8') { + return trim(utf8_decode($this->content)); + } else { + return trim($this->content); + } } //This is the startTag handler we use where we are reading the info zone (todo="INFO")