How can I stop TinyMCE from converting my HTML entities to characters?

Here’s the problem: I paste the HTML entity code for, let’s say, a service mark () into the HTML view of the editor. As soon as I switch to the “visual” tab, my entity code is turned into an actual service mark character (I guess the corresponding UTF-8 character or something? I don’t know from character encodings…). I don’t want this–I want it to stay as the entity reference.

Is there some kind of configuration I can change to stop TinyMCE from doing this? My understanding from reading the internets is that this is not the default behavior–that TinyMCE should actually be doing the opposite, and converting characters to their entities. So is this something specific to WordPress’ version of TinyMCE?

Related posts

Leave a Reply

2 comments

  1. According to this page, you can use the tiny_mce_before_init filter, make sure the entity encoding is set to named, and then add whichever special characters you want to the entities array.

  2. Thanks, fdsa!

    For posterity, here’s the actual code I used. It adds copyright, registered, trademark, service mark and euro to the array of allowed entities. I’m confused as to why some of these aren’t in there by default, as they’re really common. But in any case, this works:

    // Custom configuration for TinyMCE
    function wpsx_54398_configure_tiny_mce( $initArray ) {
    
        // Add some common entities to the default array (copy, reg, trade, service mark, euro)
        // The odd entires are the entity *number*, the even entries are the entity *name*. If the entity has no name,
        // use the number, prefixed with a hash (for example, the service mark is "8480,#8480").
        $initArray['entities'] = $initArray['entities'] . ',169,copy,174,reg,8482,trade,8480,#8480,8364,euro';
    
        return $initArray;
    
    }
    add_filter('tiny_mce_before_init', 'wpsx_54398_configure_tiny_mce');