Copied to clipboard

Flag this post as spam?

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


  • Giant Penguin 23 posts 112 karma points
    Aug 03, 2019 @ 16:17
    Giant Penguin
    0

    Cant use embed, UTF-8 is not a supported encoding name

    trying to embed a Youtuve video in the RTE, this error happens:

    System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The character set provided in ContentType is invalid. Cannot read content as string using an invalid character set. ---> System.ArgumentException: '"UTF-8"' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. Parameter name: name at System.Globalization.EncodingTable.internalGetCodePageFromName(String name) at System.Globalization.EncodingTable.GetCodePageFromName(String name) at System.Text.Encoding.GetEncoding(String name) at System.Net.Http.HttpContent.<>cDisplayClass13_0.0(Task task) --- End of inner exception stack trace --- --- End of inner exception stack trace --- at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at Umbraco.Web.Media.EmbedProviders.EmbedProviderBase.DownloadResponse(String url) in d:\a\1\s\src\Umbraco.Web\Media\EmbedProviders\EmbedProviderBase.cs:line 54 at Umbraco.Web.Media.EmbedProviders.YouTube.GetMarkup(String url, Int32 maxWidth, Int32 maxHeight) in d:\a\1\s\src\Umbraco.Web\Media\EmbedProviders\YouTube.cs:line 24 at Umbraco.Web.PropertyEditors.RteEmbedController.GetEmbed(String url, Int32 width, Int32 height) in d:\a\1\s\src\Umbraco.Web\PropertyEditors\RteEmbedController.cs:line 58 ---> (Inner Exception #0) System.InvalidOperationException: The character set provided in ContentType is invalid. Cannot read content as string using an invalid character set. ---> System.ArgumentException: '"UTF-8"' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.

  • Richard Hamilton 36 posts 158 karma points
    Jul 21, 2020 @ 14:12
    Richard Hamilton
    0

    Hi, Did you eve get an solution to this? I'm having the same problem when trying to add facebook video embed support

  • Giant Penguin 23 posts 112 karma points
    Jul 22, 2020 @ 03:36
    Giant Penguin
    0

    I have applied a custom Utf8 encoding provider (in a IComponent Initialize) I found somewhere (could not remember where, neither understand under the hood but hope someone here can input more to make it more clear)

    public void Initialize() { Encoding.RegisterProvider(new CustomUtf8EncodingProvider()); }

    public class CustomUtf8EncodingProvider : EncodingProvider
    {
        public override Encoding GetEncoding(string name)
        {
            return name.InvariantEquals("utf-8") ? Encoding.UTF8 : null;
        }
    
        public override Encoding GetEncoding(int codepage)
        {
            return null;
        }
    }
    
  • Richard Hamilton 36 posts 158 karma points
    Jul 22, 2020 @ 11:32
    Richard Hamilton
    0

    So I have added this but it doesn't seem to be running this code

     public class InitializeEncoding : IComponent
        {
            // initialize: runs once when Umbraco starts
            public void Initialize()
            {
                Encoding.RegisterProvider(new CustomUtf8EncodingProvider());
            }
    
            // terminate: runs once when Umbraco stops
            public void Terminate()
            { }
    
        }
    
        public class CustomUtf8EncodingProvider : EncodingProvider
        {
            public override Encoding GetEncoding(string name)
            {
                return name.InvariantEquals("utf-8") ? Encoding.UTF8 : null;
            }
    
            public override Encoding GetEncoding(int codepage)
            {
                return null;
            }
        }
    
  • Giant Penguin 23 posts 112 karma points
    Jul 22, 2020 @ 18:51
    Giant Penguin
    0

    I forgot to note that it is a IComponent and then must be registered through a IUserComposer, e.g.

    public class SiteComposer : IUserComposer
    {
        public void Compose(Composition composition)
        {
            composition.Components().Append<InitializeEncoding>();
        }
    }
    
  • Richard Hamilton 36 posts 158 karma points
    Jul 22, 2020 @ 10:41
    Richard Hamilton
    0

    Thank you GP, I will try this But strange how this is not already built-in

  • Giant Penguin 23 posts 112 karma points
    Jul 22, 2020 @ 19:02
    Giant Penguin
    0

    I do not know, I cannot explain. It is a weird issue, but see that it just happens to a small number of Umb site (not much report about this issue).

Please Sign in or register to post replies

Write your reply to:

Draft