Support » Plugin: dbview » [Plugin: dbview] Charset encoding (encodeHtmlEntities) is broken by using UTF-8

  • Resolved AleksCee


    I have installed a fresh new test-WordPress and if I query a SQL like this:

    select * from wp_posts

    I only get the first “Wellcome”-Post from the german WP-Instaltion. The Umlauts are all broken and the Post is end with the first “-” in the Post.
    I have try to find out where the code goes broken… And I found this:

    if ($this->encodeHtmlEntities)
    $dval = htmlentities($dval);

    in “DBViewTable.class.php” at line 153.

    If I set the Calls-Attribut: public $encodeHtmlEntities = false
    all seams to by fine.

    So I take a look at the PHP-Doc and found this:
    “If omitted, the default value for this argument is ISO-8859-1 in versions of PHP prior to 5.4.0”

    So I set the Calls Attribut back to true and change this:

    $dval = htmlentities($dval, ENT_COMPAT, get_option(‘blog_charset’));

    Now it’s work fine…. can you take this into account.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author john ackers


    Aleks, thanks for reporting the issue and solving it! I will look at this tomorrow and correct plugin.

    Plugin Author john ackers



    Having looked into this more closely, in particular, this very helpful article, it looks like I shouldn’t be doing any encoding/decoding for individual HTML elements. Only the special HTML characters like <, & and > etc need to be handled.

    So I am about to commit a new version that removes htmentities() and instead uses esc_textarea(), a WP function used by many plugins. It works for umlauts and the string ‘Iñtërnâtiônàlizætiøn’. But the test is meaningless as I am using the default WP charset UTF-8. Can you tell me what character encoding you are using, so I can be sure that this fix works for you as well as me.

    By the way, esc_textarea() calls htmlspecialchars() which according to the article above, should also be passed the blog_charset, in the same way as you suggest above. But if you don’t have problems with WP core or any other plugins, you shouldn’t have any problems with the updated dbview.


    Plugin Author john ackers


    Actually re-reading the title of your article makes it clear u r using UTF-8 !


    I’ve updated the plugin and it now works correctly for me.



    Plugin Author john ackers


    Phew. Thanks Alex for the update.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: dbview] Charset encoding (encodeHtmlEntities) is broken by using UTF-8’ is closed to new replies.