1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 weird characters after import

Discussion in 'Installation, Upgrade, and Import Support' started by Michael Eaton, Nov 22, 2011.

  1. Michael Eaton

    Michael Eaton Member

    Hey Guys,

    I've moved my xenforo installation over to a new web host and have some issues with encoding i believe. For instance apostrophies now show up like: "’" and pound signs show up as "£" etc..

    How can i fix this?

    Thanks,

    Michael
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    This is probably due to the database collation.

    What is it set to currently?
     
  3. Michael Eaton

    Michael Eaton Member

    Hi Brogan,

    How do I find that out?

    Thanks,

    Michael
     
  4. Michael Eaton

    Michael Eaton Member

    Nevermind - i found it.. its 'utf8_general_ci'
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yep. This is clearly a character encoding issue. Since the source is already UTF8 this thread might help:

    http://xenforo.com/community/threads/converting-to-utf-8-issues.21406/#post-270879

    He modified this file:

    library/XenForo/Importer/Abstract.php

    And changed this code:

    Code:
    	/**
    	 * Convert the given text to valid UTF-8
    	 *
    	 * @param string $string
    	 * @param boolean $entities Convert &lt; (and other) entities back to < characters
    	 *
    	 * @return string
    	 */
    	protected function _convertToUtf8($string, $entities = null)
    	{
    		// note: assumes charset is ascii compatible
    		if (preg_match('/[\x80-\xff]/', $string))
    		{
    			if (function_exists('iconv'))
    			{
    				$string = @iconv($this->_charset, 'utf-8//IGNORE', $string);
    			}
    			else if (function_exists('mb_convert_encoding'))
    			{
    				$string = mb_convert_encoding($string, 'utf-8', $this->_charset);
    			}
    		}
    
    		$string = utf8_unhtml($string, $entities);
    
    		return preg_replace('/[\xF0-\xF7].../', '', $string);
    	}
    }
    
     
  6. Michael Eaton

    Michael Eaton Member

    Oh - I guess this will only fix it if i'm importing? The site was imported from phpBB a long time ago, i just moved hosts recently.. can you confirm?

    Thanks,

    Michael
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The importer won't fix corruption in the source database. I assumed the corruption was happening during your import to XenForo.
     
  8. Michael Eaton

    Michael Eaton Member

    Nah, the forum has been running a while, i switched web hosts using phpmyadmins export/import.. any other ideas?

    Thanks,

    Michael
     
  9. Brogan

    Brogan XenForo Moderator Staff Member

    It sounds as if the characters were corrupted during the export/import from the old to new host.

    You would have to use SQL queries to replace any existing content in the database.

    Unless you can redo the export/import.
     
  10. Mike

    Mike XenForo Developer Staff Member

    If it happened when moving servers, then it happened at one of three places:
    1. When the data was dumped. Should be unlikely, but depends on the method.
    2. During the transport. If the file was edited by someone, it could have been changed from UTF-8 to a Latin-1 style version, which would have this behavior.
    3. During the restore. Again, possible, particularly if done via a web interface rather than the command line.
    I'd recommend redoing the dump (via mysqldump if possible) and retrying the restore via mysql at the command line. You may need your host to help.
     

Share This Page