Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

TppRichText and Unicode

edited July 2013 in General
Subject : TppRichText and Unicode

I am using ReportBuilder 14.08 Build 48. Also Delphi XE2.

I have a TppRichText component on my report.

I build up text in that component programmatically.

My previous version of Delphi and ReportBuilder was a pre Unicode
version. Everything worked OK.

Now I see the raw rich text on the report.

Something beginning as:-

{\rtf1\ansi\ansicpg1252\deff0\deflang3081{\fonttbl{\f0\fnil Tahoma;}}

I note the word ansi and the font Tahoma.

Previously to programmatically insert the word Hello into the component
I would:-
1) find the end characters which was like \par
2) strip them off
3) append Hello
4) write the end characters.

Now that approach doesn't work.

1) Do I need to escape all my text?
My text is defined as String, and thus is Unicode.
It could be the English word Hello but could be a Japanese word.

2) If I need to escape all my text is there a routine to do that?

3) What other way/s is there to get Unicode into the TppRichText component?

Regards,
Peter Evans

Comments

  • edited July 2013
    Peter,

    TppRichText is a wrapper for Delphi's TRichEdit, which itself is a wrapper
    for the Windows RichEd.dll. Use the SelStart, SelLength, and SelText
    properties (there is also a SelectAll method) to select, replace, append or
    insert text. Use SelAttributes to specify the Font properties for the
    selected text (SelAttributes.Name = Font.Name, etc).

    Example:

    myRichText.SelectAll;
    myRichText.SelText := 'Hello World';


    The RTF spec and the Windows implementation specifies the raw rtf data such
    as {\rtf1\ansi\ansicpg1252\deff0\deflang3081{\fonttbl{\f0\fnil Tahoma;}}
    is always AnsiString with Unicode characters being streamed as \CodePoint.
    To see this, use WordPad to create a document with Unicode characters and
    then save to .RTF and re-open in NotePad.


    Best regards,

    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited July 2013
    On 17/07/2013 12:43 AM, Nard Moseley (Digital Metaphors) wrote:


    Thank you for that advice. I am working on it.

    Regards,
    Peter Evans
This discussion has been closed.