Mixing Right-To-Left and Left-To-Right Text

4 posts, 0 answers
  1. Tom
    Tom avatar
    2 posts
    Member since:
    Sep 2013

    Posted 05 Sep 2013 Link to this post

    It appears as though the WPF RichTextBox doesn't play well with mixing LTR and RTL characters in the same string. 

    Pasting the following string into the TextBox gives mixed results including displaying question marks, flipping brackets and changing the position of neutral characers. The issue seems to persist even when putting an LRM character in front of the bracket, as seen in this article: http://www.iamcal.com/understanding-bidirectional-text/.

    [KEY]="مرحبا العالم"

    Pasting the same text into (for example) Notepad++ displays the text just fine. Is this a known issue, and are there any plans to support this?

    Thanks,
    Tom
  2. Vasil
    Admin
    Vasil avatar
    124 posts

    Posted 10 Sep 2013 Link to this post

    Hello Tom,

    Thank you for writing.

    As the clipboard keeps content in several formats, the paste functionality in RadRichTextBox uses its RtfFormatProvider and HtmlFormatProvider in order to insert the content. When the two format providers are referenced, the PasteCommand tries to create a document out of the RTF content of the clipboard. If it fails for some reason (e.g. the RTF is invalid or not supported by RtfFormatProvider), the paste falls back to HTML. In case HtmlFormatProvider cannot handle the clipboard content as well, the plain text from the clipboard will be inserted in the document. You could find more information on the matter in this help article.

    In this context could you please elaborate where the string is copied from and which of the above format providers are referenced in your application? You could try to isolate the problem by saving the string in .html and .rtf file formats and import them in RadRichTextBox. Other important information we need to further investigate the problem is what exact version of RadControls for WPF you are using as well as in what text direction (left-to-right or right-to-left) you are observing these problems. It would be great if you could send us some repro documents and screenshots demonstrating the issues.

    Looking forward to your reply.


    Regards,
    Vasil
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Tom
    Tom avatar
    2 posts
    Member since:
    Sep 2013

    Posted 16 Sep 2013 Link to this post

    Hi Vasil,

    Thanks for getting back to me.

    This issue is reproducible in the Telerik WPF Demos for Windows 7. I downloaded the demos application on my Windows 7 machine in order to try and reproduce the mixed RTL and LTR text problems I was seeing in our own application. The following should see the issue come up:

    1. Open the "Telerik WPF Demos" application.
    2. Open the RichTextBox example and clear all of the text from it
    3. Go to http://www.translate.google.com and translate "hello world" from English to Arabic
    4. Copy the Arabic text to clipboard
    5. In a text editor (I used Notepad++), type the following: [KEY]=""
    5. Paste the Arabic text between the quotations. You should now have the following: [KEY]="مرحبا العالم"
    6. Copy+Paste the whole line (i.e. so that RTL and LTR text are mixed) into the RichTextBox example
    7. The neutral characters in the text (brackets, quotations) do not keep their correct order. The RichTextBox also does not appear to to recognize Left-To-Right implicit markers which would normally be used before the quotation marks and brackets to maintain their position in the string (LRM implicit marker is U+200E, please see the linked article in my first post).

    I have attached a screenshot to show you what I am seeing in the RichTextBox example upon pasting the string from Notepad++.

    Thanks for your time,
    Tom
  5. Vasil
    Admin
    Vasil avatar
    124 posts

    Posted 19 Sep 2013 Link to this post

    Hi Tom,

    Thank you for the detailed follow up.

    We managed to reproduce the issue and logged it for revision. I also added a feature request for support of left-to-right (LRM) character which is used in such bi-directional (mixed) left-to-right and right-to-left strings.

    We updated your Telerik points in appreciation of your involvement. Don't hesitate to contact us if you have other questions or comments.

    Regards,
    Vasil
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top