+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / encoding characters in RadEditor

encoding characters in RadEditor

19 posts, 0 answered
  1. Nick
    Nick avatar
    91 posts
    Registered:
    04 Aug 2008
    16 Feb 2010
    Link to this post
    Hi guys,

    I have recently noticed a problem whereby if i encode a special character in the RadEditor as generic content (such as the pound symbol for british currency - £), save the content and then return to edit the content at a later time, the encoding has been replaced by the actual symbol. This is causing many problems for the content team as they are not well versed in how to encode characters etc and so invalid HTML makes it's way into our pages.

    Is there anything i can do to rectify this problem? i am pretty sure i have encountered something similar before, but cannot remember the resolution.

    Thanks,
    Nick
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Feb 2010
    Link to this post
    Hi Nick,

    You can use custom filters with RadEditor control. Sample code is shown below

    <script type="text/javascript">    
    function OnClientLoad(editor, args)    
    {    
       editor.get_filtersManager().add(new RadEditorCustomFilter());    
    }    
    RadEditorCustomFilter = function()    
    {    
       RadEditorCustomFilter.initializeBase(this);    
       this.set_isDom(false);    
       this.set_enabled(true);    
       this.set_name("RadEditor filter");    
       this.set_description("RadEditor filter description");    
    }    
    RadEditorCustomFilter.prototype =    
    {    
       getHtmlContent : function(content)    
       {    
            //Make changes to the content and return it    
            //Convert all symbols to their numeric HTML entities    
            newContent = content.replace(/£/gi, "£");     
       
         return newContent;    
       }  
    }    
    RadEditorCustomFilter.registerClass('RadEditorCustomFilter', Telerik.Web.UI.Editor.Filter);    
    </script>


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Nick
    Nick avatar
    91 posts
    Registered:
    04 Aug 2008
    16 Feb 2010
    Link to this post
    You guys never fail to amaze me with your super quick responses :-)

    what file do i put this into ivan?

    is all of this code necessary? if so could you run through the purpose of each block please, just so i learn something here and won't have to hassle you next time :-)

    one last thing, what's the purpose of the "/£/gi"? i have never seen this kind of syntax before!

    thanks ever so much :-)
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Feb 2010
    Link to this post
    Hello Nick,

    You need to put the code in each template where you want to modify the special chars rendering. You have to map the external templates and subscribe for OnClientLoad event of RadEditor control declared in your template. You should add the script in the mapped template. More information about RadEditor's custom filters can be found at Content Filters
    Flags 'g', 'i' and 'gi' can be used after the final slash to specify a global, case-insensitive or global, case-insensitive search respectively. More information at egexp_special_characters

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Nick
    Nick avatar
    91 posts
    Registered:
    04 Aug 2008
    17 Feb 2010
    Link to this post
    oops, i should know that, i'm aware of RegExp!!

    What control template should i be adding any code to for the RadEditor that is used when editing a page?

    Also, is this compatible with sitefinity 3.2 sp2?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Feb 2010
    Link to this post
    Hello Nick,

    If you are talking about GenericContent control, you should edit GenericContentDesigner template.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Eric
    Eric avatar
    19 posts
    Registered:
    06 Nov 2007
    10 Aug 2010
    Link to this post
    I followed all these instructions and when I try to save the generic content, it doesnt save the special character.   Any ideas?
    <script type="text/javascript">
        function OnClientLoad(editor, args)
        {
           editor.get_filtersManager().add(new MyFilter());
        }
        MyFilter = function()
        {
           MyFilter.initializeBase(this);
           this.set_isDom(false);
           this.set_enabled(true);
           this.set_name("RadEditor filter");
           this.set_description("RadEditor filter description");
        }
        MyFilter.prototype =
        {
           getHtmlContent : function(content)
           {
             var newContent = content;
             //Make changes to the content and return it
             newContent = newContent.replace(/ō/gi, "&#333;");
             return newContent;
           },
           
           getDesignContent : function(content)
           {
             var newContent = content;
             //Make changes to the content and return it
             newContent = newContent.replace(/ō/gi, "&#333;");
           
             return newContent;
           }
        }
        MyFilter.registerClass('MyFilter', Telerik.Web.UI.Editor.Filter);
        </script>
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Aug 2010
    Link to this post
    Hello Eric,

    I checked the code and it looks fine. I prepare a sample video and put some alerts that shows the exact content.
    Do you see this behavior at your end and is this the behavior you expect, because this is what the code does.
    The description of the two modes is below. If you want to make some manipulations with content in design you could consider using &amp;#333

    • getDesignContent - Called when the editor is moving from some other mode to DESIGN mode
    • getHtmlContent - Called when the editor is moving from some other state to HTML mode


    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Eric
    Eric avatar
    19 posts
    Registered:
    06 Nov 2007
    10 Aug 2010
    Link to this post
    It works until I save the content, then it just converts it to a different character.  Example:  &trade; gets converted to T, ō gets converted into an o

    I don't understand why it's so difficult to display simple characters.  Why is all this extra work necessary?  Why can other cms's editors work out of the box, but the radeditor doesn't?

  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Aug 2010
    Link to this post
    Hi Eric,

    The &trade;  is  TM. You could try the online demo of RadEditor control. Try turning off . Check your encoding as well.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Eric
    Eric avatar
    19 posts
    Registered:
    06 Nov 2007
    11 Aug 2010
    Link to this post
    I know &trade is TM.

    Again I ask the question, why doesnt the radeditor that is built into sitefinity allow the use of special characters? 

    What am I supposed to tell my boss when he asks why is all my time spent troubleshooting a stupid problem?
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    12 Aug 2010
    Link to this post
    Hello Eric,

    The content area of RadEditor is a standard editable IFRAME element and it does allow working with special characters. The problem that you experience is definitely an encoding problem not related to our control, because as we demonstrates in our earlier messages we were unable to reproduce it neither on our end nor on in the live demos.

    Were you able by any chance to reproduce the reported problem in the live demos of RadEditor?

    Could you please isolate the problem in a sample working project and send it for examination via your support ticket? We will examine the project with priority and do our best to provide a solution as early as possible.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Eric
    Eric avatar
    19 posts
    Registered:
    06 Nov 2007
    15 Aug 2010
    Link to this post
    I have no doubt it works on your end, but the problem is when to data is saved within any RadEditor in sitefinity, the special charactors are lost.  It does this on 30+ sites dating back to Sitefinity 3.2. 
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Aug 2010
    Link to this post
    Hello Eric,

    1. Check the encoding of your database

    2. Check [sf_CmsControlProperty] where the actual content is saved and see what is actually stored in this table. Check the encoding as well.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. Eric
    Eric avatar
    19 posts
    Registered:
    06 Nov 2007
    15 Aug 2010
    Link to this post
    What should the database and table's encoding be?
  16. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Aug 2010
    Link to this post
    Hi Eric,

    You should not have problems with SQL_Latin1_General_CP1_CI_AS

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  17. Eric
    Eric avatar
    19 posts
    Registered:
    06 Nov 2007
    15 Aug 2010
    Link to this post
    for some reason it's set to swedish instead of general, would that be causing certain symbols not to show?
  18. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Aug 2010
    Link to this post
    Hello Eric,

    I believe that the problem comes from the encoding, because we are not able to reproduce such problems on our servers.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. Eric
    Eric avatar
    19 posts
    Registered:
    06 Nov 2007
    16 Aug 2010
    Link to this post
    The database is encoded correctly.  It allows some special characters to be saved but not the two we actually need like &trade; and &#333; 

    We can enter those in the MySql db manually, but when using SITEFINITY, those get converted to a T and an o. 

    whatever the case, Im done wasting my time.
Register for webinar
19 posts, 0 answered