Ticket T937000
Visible to All Users

How to change the encoding of the HTML text copied to the Clipboard from RichEditControl

created 4 years ago

hi.

If you copy Japanese in HTML format, the characters will be garbled.
I set RichEditControl.Options.ClipboardFormats.AllowHtml to true.
charset = utf-8
Despite declaring, the text seems to be encoded in shift_jis.
Encoding.Default of Japanese version Windows is shift_jis, so it may be affected.

thank you.

Comments (2)
DevExpress Support Team 4 years ago

    Hi,

    I could not reproduce the issue on my side. Could you please send us the Clipboard's content for research? You can collect the Clipboard's content and save it to a file using the Free Clipboard Viewer tool.
    We will check how this text is copied to HTML and pasted to our RichEditControl.

      Upload the image.
      I think that the cause of the garbled characters is that "あ" is 0x82A0.

      Answers approved by DevExpress Support

      created 4 years ago

      Thank you for your clarification. However, I still could not replicate the problem locally.
      The RichEditControl.Options.Export.Html.Encoding property does not affect the HTML text encoding when data is copied to the Clipboard.
      The HTML export options are initialized when data in the HTML format is obtained from the Clipboard.

      C#
      string ExportToHtml() { if (exportToHtml != null) return exportToHtml; else { if (htmlImageSourceType == HtmlImageSourceType.Linked) { IUriProviderService currentService = DocumentModel.ReplaceService<DevExpress.Office.Services.IUriProviderService>(new UriProviderService(false)); exportToHtml = DocumentModel.InternalAPI.GetDocumentHtmlContent(new HtmlClipboardUriProvider(){HtmlImagePath = htmlImagePath}, new HtmlDocumentExporterOptions() {ExportToClipboard = true}); DocumentModel.ReplaceService<DevExpress.Office.Services.IUriProviderService>(currentService); } ...

      You can change the built-in behavior and specify an appropriate text encoding directly by replacing CopySelectionCommand with a custom one. I recommend you review the following Code Example to get started: How to customize copy and paste commands.

      Should you encounter any difficulty while implementing this workaround, let us know. We will do our best to help.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.