[resolved] Plugin character encoding problem (7 posts)

  1. matobodo
    Posted 1 year ago #

    I'm writing a plugin and i have problem with character encoding. i'm using characters e.g. (ľ,š,č,ť,ž,ý). Here is code:

    add_action('admin_menu', 'receptar_admin_actions');
    function receptar_admin_actions() {
        add_menu_page('Receptár', 'Receptár', 'manage_options', __FILE__, 'receptar_admin', plugins_url( __FILE__ . 'images/icon.png' ), 26);

    i don't know how to fix it. i'm sorry if already is here this topic but i haven't found it

    thanks for any help

    Sorry for my english

  2. matobodo
    Posted 1 year ago #

    * i'm using characters e.g. (ľ,š,č,ť,ž,ý) and on the page i just see �

  3. bcworkz
    Posted 1 year ago #

    Be sure your text editor is saving your code pages with UTF-8 encoding with no byte order mark. Your site should also be using UTF-8 encoding or your code page will need to provide hexcodes in place of extended characters. The site's encoding should be specified in the first meta tag seen when you view the source of an admin page in your browser.

    Also be sure your browser is set to allow pages to select their own fonts. It shouldn't matter, but I like to tell my browser to use UTF-8 encoding on pages.

    All of your extended characters do exist in the default admin menu font, they display fine as a menu item on my 100% UTF-8 site.

  4. matobodo
    Posted 1 year ago #

    i saved files with utf-8 encoding, site meta tag have utf-8, everythig is set with utf-8 but it doesn't work

    here is my admin menu:

  5. bcworkz
    Posted 1 year ago #

    So the extended characters all display correctly except for your menu label? That narrows down where the problem can lie. If the file is correctly saved, the only other place that could be the problem is your FTP client is using the wrong charset for text mode.

    Usually the auto detect works fine, you might try a setting that forces UTF-8 to be used. Also, your PHP install may be using the wrong charset in its locale setting.

    Run this from a PHP page on your server:

    	 echo system('locale -a');

    This lists all available locales, find your language_Country code with .utf8 after it and make note of the exact text string. Let's say it's "cs_CZ.utf8". Add the following to your wp_config.php file so PHP is using the right locale:
    @setlocale(LC_CTYPE, "cs_CZ.utf8");

    This actually just sets the charset, the language and country are not changed. Use LC_ALL to change everything. It doesn't seem like it should matter for this issue, but double check with a hex editor that your text editor is not saving a byte order mark (BOM) at the beginning of the file. The first 3 hex codes should be 3C 3F 70 (for '<?p') and not EF BB BF. Some editors insert a BOM with no warning. In fact, anything in front of the "<?php" on non-template files can cause problems, not just a BOM. A good thing to check even without charset issues.

  6. matobodo
    Posted 1 year ago #

    i haven't do nothing as you write in your second post but it is working now and yesterday it wasn't working, i don't know what happened, i din't change anythig in my files

    thanks for help

  7. bcworkz
    Posted 1 year ago #

    Crazy computers! Possibly some sort of caching issue. I'm just glad it's working because I'm out of ideas :)

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.