You might be asking yourself, why can’t you just copy-out the whole symbol? Why do you need it’s entity HTML code? And I’ll tell you why. Because the browser may get the encodings wrong. One symbol might show up as another, or as and unknown character. It may even mix-up with the preceding character if the browser will get it wrong. I’m sure you wouldn’t like such user-experience on your site.

Text symbols are encoded into some numbers, and then interpreted by browsers as characters of some encoding system. When you write special characters that are outside of the standard 7-bit ASCII range straight into your HTML there are things to consider. If you’ll just paste 3-byte characters of some encoding right into your HTML code, without “escaping” them (e.g. converting them to their symbol entity codes), you might get into big trouble. This is because HTML code should be written and read in ASCII encoding. If you’ll paste the symbols from other encoding systems, like Unicode, or UTF-8, you may get browsers treating your several-byte symbols just like several different symbols. So remember to write your HTML source code plainly in ASCII. Instead of writing symbols, always write their entities.

But for converting Romanian characters you can use a php method which is much usefull:

function characters_clean($string) {
    $specialCharacters = array(
        'ã' => 'ă',
        'ă' => 'ă',
        'ă' => 'ă',
        'Ă' => 'Ă',
        'â' => 'â',
        'Â' => 'Â',
        'î' => 'î',
        'Î' => 'Î',
        'ş' => 'ş',
        'Ş' => 'Ş',
        'ș' => 'ș',
        'Ș' => 'Ș',
        'ț' => 'ţ',
        'Ț' => 'Ţ',
        'ţ' => 'ţ',
        'Ţ' => 'Ţ',
    );
    while (list($character, $replacement) = each($specialCharacters)) {
        $string = str_replace($character, $replacement, $string);
    }
    return $string;
}

The example is for Romanian language but you can customize for your language as well. For usage, use the php function html_entity_decode or htmlspecialchars_decode:

$str = characters_clean($string);
html_entity_decode($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
or
htmlspecialchars_decode($str);
JSC0d3's Logo
About JSC0d3

JSC0d3 is an entrepreneur, online marketer, and an employee of an IT company. When not building websites, creating content, or helping customers improve their online business, spend time with their wife and two beautiful children. Although he still feels new in WordPress, he enjoys sharing what he has learned with all of you! If you want to get in touch with him, you can do this through this website.

On the same idea

Posted by | February 9, 2019

WordPress' wp_link_pages() function, used for displaying page links in multi-page posts, lacks one big feature You can display a list of...

Posted by | December 14, 2018

Preliminary step: Testing whether the code complies with the format of a fiscal identification code (CIF) That is, the maximum length should be 10...

Posted by | November 8, 2017

Nowadays, a lot of bloggers choose to remove HTML tag from WordPress websites However, for beginners and newbies in this field, they may feel...

Previous PostBackNext Post

Leave here an impression