How to merge two rtf strings

  • Hi + tx for every input!

    I have two RTF strings (= both starting with {\rtf1\ansi \...) and I want to concat them.

    I tried:
    WPRichText1.SelectionAsString := rtf1;
    WPRichText1.SelectionAsString := rtf2;

    But this does not work.

    Thanks!
    Bernd

    • Offizieller Beitrag

    Hello,

    It is possible that in the code above the second assignment overwrites the first one.

    I would use LoadFromString instead.

    {:: Load the text from a string. Insert at current position. This is slower than using InputString and InputText }
    function LoadFromString(const X: AnsiString; FormatString: string = '';
    WithClear: Boolean = FALSE): Boolean;

    • Offizieller Beitrag

    Found in WPCtrMemo.pas - WPTools 7:

    {:: Load the text from a string. Insert at current position. This is slower than using InputString and InputText }
    function LoadFromString(const X: AnsiString; FormatString: string = '';
    WithClear: Boolean = FALSE): Boolean;

    >> Additionally: How do I retrieve the resulting RTF (=the base RTF string containing encodings)?

    I would use the function AsANSIString which also uses a formatstring to sepcify the format, such as "RTF-nobinary".

    Please use ANSIString and not unicode strings since RTF is a single byte char based format (originally ASCII!)

    Julian