Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • JessicaGUA 7 posts 118 karma points
    1 week ago

    Umbraco 14 : Rich Text Editor displaying unicode characters

    Update : changing from IContent to IPublishedContent seems to solve this issue. I don't really get the difference and when to use one or another...

    Hi everyone,

    First of all, this is my first time ever posting on a forum because I'm new to development (started in January). Please excuse my lack of experience and if my request may seems dumb. Plus, excuse my grammar/vocabulary errors, I'm French...

    So, I have a problem when I try to display the content of my Rich text Editor. It renders unicodes and HTML tags. I solved the HTML tags' problem by using a Regex. But I don't know what to use for unicodes.

    For example :

    • Text editor contains : Retour en photo du Workshop consacré aux retours d’expériences
    • What is rendered : {"markup":"\u003Cp\u003ERetour en photo du Workshop consacr\u00E9 aux retours d\u2019exp\u00E9riences

    Some context elements; I identify my Document with:

    IContent latestNews = _contentService.GetPagedOfType(
            out total,
        ).OrderByDescending(x => x.GetValue("publishedDate"))

    I display it with:

    string latestNewsContent = Regex.Replace(latestNews.GetValue("content").ToString(), @"<[^>]*>", String.Empty);

    PLEASE : comment with details and a maximum of explanations because, I repeat, I am a newbie... Thank you in advance and feel free to reach me for further informations.

  • Yakov Lebski 581 posts 2249 karma points
    1 week ago
    Yakov Lebski

    I think it encoder issues

    in Startup.cs under ConfigureServices or before services.AddUmbraco or in Composer add

         var settings = new TextEncoderSettings(UnicodeRanges.All);
  • JessicaGUA 7 posts 118 karma points
    1 week ago

    Thanks for your message, I will try it. For the moment, changing for a IPublishedContent and looking for Value("content") seems to display the content as expected. Thanks again, have a nice day !

  • Sebastiaan Janssen 5057 posts 15513 karma points MVP admin hq
    1 week ago
    Sebastiaan Janssen

    Please don't do this Startup.cs modification, this is not the problem! 😅 Instead, Nik has explained the problem nicely.

  • Nik 1604 posts 7228 karma points MVP 7x c-trib
    1 week ago

    Hi Jessica,

    Firstly, welcome to Our and the Umbraco community :-)

    I wanted to address your additional query around IContent and IPublishedContent.

    The simple rule of thumb is that IContent is what is used by the Umbraco back office and customisations that integrate with that part of the system to update content data. Where as IPublishedContent is what should be being used on the front end of the site, in your Razor Views etc.

    IContent and IMedia represents the raw values of content and media and are accessed via the ContentService and MediaService respectively. These access data via the database directly.

    IPublishedContent represents both Content and Media, and they come from the Published Content Cache (currently NuCache). They are much more performant when querying and rendering out data but they are essentially read-only versions of the currently published data. They also take advantage of Property Value Converters that convert database stored data into more render/user friendly data for the front end - and example of this is the MultiNodeTreePicker property editor. In the database this stores the UDI's of the picked content, however the Property Value Converter will convert it to a list of IPublishedContent.

    Hopefully that helps with your understanding of when you should find yourself using each type? If you have more questions, feel free to ask.



  • JessicaGUA 7 posts 118 karma points
    1 week ago

    Hey Nik,

    Thank you so much for your kindness through this detailed message. Every explanation is so much appreciated and made some things more easy to understand and use in code.

    I will definitely deeper for every term you have used because I am not really familiar with every single ones... But things are clearer now, thank you so much for that.

    Have a nice day, and again, thanks for the kindness in your explanations and the time you took to write those down.


Please Sign in or register to post replies

Write your reply to: