WordPress.org

Forums

WP Mobile Detector
[resolved] Character Encoding Issue (2 posts)

  1. bitlost
    Member
    Posted 1 year ago #

    Found that the plugin was causing strange character encoding issues. To fix I added these two lines to function.php (websitez_filter_advanced_page function)

    Here is the original code...

    /*
    Filter content for an advanced mobile device
    */
    function websitez_filter_advanced_page($html){
    	if (class_exists('DOMDocument')) {
    		try{
    			//Resize the images on the page
    			$dom = new DOMDocument();
    			$dom->loadHTML($html);
                            .....

    Here is what I added

    /*
    Filter content for an advanced mobile device
    */
    function websitez_filter_advanced_page($html){
    	if (class_exists('DOMDocument')) {
    		try{
    			//Resize the images on the page
    			$html = mb_convert_encoding($html, 'utf-8', mb_detect_encoding($html));
    			$html = mb_convert_encoding($html, 'html-entities', 'utf-8');
    
    			$dom = new DOMDocument();
    			$dom->loadHTML($html);
                            ....

    http://wordpress.org/plugins/wp-mobile-detector/

  2. websitezcom
    Member
    Plugin Author

    Posted 1 year ago #

    What type of encoding does your DB use? What encoding is being set inside your WP Admin? You might be able to set the encoding right on the $dom variable instead of converting. I will see if I can find anything related to this with the DOMDocument class.

    I would hesitate in using this type of a fix because it can cause other issues.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Mobile Detector
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.