Declined
Last Updated: 20 Apr 2023 12:54 by ADMIN
Gustavo
Created on: 12 Apr 2023 08:28
Category: RichTextEditor
Type: Bug Report
1
RadRichTextEditor: Copying Spanish text from a web page to the editor inserts special characters in the text

Copy some text from the introduction docs page:

Paste in RadRichTextEditor from the Demo app:

 

4 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 20 Apr 2023 12:54

Hello,

We have decided to decline the issue as it is .NET specific. The following KB article was published for bringing more information on this topic if any other customers encounter this behavior:

https://docs.telerik.com/devtools/winforms/knowledge-base/incorrect-spanish-symbols-pasted-in-radrichtexteditor 

 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 13 Apr 2023 13:35

Hello,

After testing with .NET 4.0 and .NET 4.5.2 I can confirm the observed difference in the HTML content coming from the Clipboard without any custom implementation of handling the CommandExecuting event, just the default RadRichTextEditor with its functionality out of the box:

Case 1 .NET 4.0

Case 2 .NET 4.5.2

In both cases the standard Label uses the same content: 

this.label1.Text = Clipboard.GetDataObject().GetData(DataFormats.Html).ToString();

It seems to be an issue with .NET 4.0 which is addressed in the later versions:

https://stackoverflow.com/a/38067962 

https://metadataconsulting.blogspot.com/2018/01/C-NET-4-0-Fix-Encoding-Mapping-from-Windows-1252-to-UTF-8-using-Clipboard-GetText-TextDataFormat-Html-showing-funny-bad-characters.html 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 12 Apr 2023 14:33

Hi,

I would like to follow up with some additional information related to this item. Enabling the option called "Beta: Use Unicode UTF-8 for worldwide language support" has a positive impact of the copied data to the clipboard:

We should have this Windows setting in mind when working on this item.

 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 12 Apr 2023 09:35

Hello, Gustavo,

Thank you for reporting this undesired behavior. We will do our best to improve the behavior in RadRichTextEditor and handle the special characters in a proper way no matter what encoding comes from the clipboard's data.

Currently, the possible solution that I can suggest is to use UTF-8 encoding for inserting the HTML content in RadRichTextEditor: 

    public partial class RadForm1 : Telerik.WinControls.UI.RadForm
    {
        public RadForm1()
        {
            InitializeComponent();
            this.radRichTextEditor1.CommandExecuting += RadRichTextEditor1_CommandExecuting;
        }

        private void RadRichTextEditor1_CommandExecuting(object sender, Telerik.WinForms.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
        {
            if (e.Command is PasteCommand)
            {
                e.Cancel = true;

                string html = Clipboard.GetDataObject().GetData(DataFormats.Html).ToString();
                // Create a UTF-8 encoding.
                UTF8Encoding utf8 = new UTF8Encoding();

                // Get the encoded html string.
                byte[] encodedBytes = utf8.GetBytes(html);

                // Decode bytes back to string.
                String decodedString = utf8.GetString(encodedBytes);

                if (decodedString != null)
                {

                    HtmlFormatProvider provider = new Telerik.WinForms.Documents.FormatProviders.Html.HtmlFormatProvider();
                    RadDocument htmlDoc = provider.Import(decodedString.Substring(decodedString.IndexOf(@"<html>")));
                    this.radRichTextEditor1.RichTextBoxElement.ActiveDocumentEditor.InsertFragment(new DocumentFragment(htmlDoc));

                }
            }
        }
    }

I believe that this would fit the precise case.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.