Unicode with Fastreport 4.14 and Firebird

edited March 2014 in FastReport 4.0
Hello,

I'm using Firebird 2.5, accessing data in Delphi 2010 with ZEOS-lib. Database charset is UTF-8 for all textual fields and in Delphi and my application all works fine.
Now I try to generate a report with Fastreport 4.14. I use the IBXDatabase-Component and IBXQuery in Fastreport.

The problem is, that german "umlauts" ar not displayed correct. The text looks like this:
should be:
wrote:
Der Apfel und andere Fr??chte.
in Fastreport:
wrote:
Der Apfel und andere Fr????chte.

In this forum I found the response to set RTLeading = true, but it doesn't change anything.

How can I get the correct unicode-Strings displayed in my report?

[edit]
I can set a frxDBDatabase on my form linked to frxReport, add a Zeos-Query and give these data to the report - that works fine.
But I like to define the data-access in my report, not in the Delphi-Sources. Is this possible too?

Thanks,
Siegbert

Comments

  • edited 8:50PM
    Hello,

    searching google shows me this way to get a workaround:
    - on the form add the event "OnUserFucntion" to the frxReport1-component
    - insert code (see below) in the generated function in Delphi
    - add the function to frxReport in the form-create-event
    - use the new function in report to convert UTF-8 to WideString


    Code for the frxReportUserFunction:
      if ansicomparetext('UTF8Decode', MethodName) = 0 then begin
        try
          result := UTF8Decode(params[0]);
        except
          result := 'FEHLER';
        end;
      end;
    
    Code for adding function in form.create:
      frxReport1.AddFunction('function UTF8Decode(const S: UTF8String): WideString');
    

    So code in Delphi looks like this:
    type
      TfrmPrint = class(TForm)
    ...
        function frxReport1UserFunction(const MethodName: string; var Params: Variant): Variant;
    ...
    end;
    
    procedure TfrmPrint.FormCreate(Sender: TObject);
    begin
      frxReport1.AddFunction('function UTF8Decode(const S: UTF8String): WideString');
    end;
    
    function TfrmPrint.frxReport1UserFunction(const MethodName: string;
      var Params: Variant): Variant;
    begin
      if ansicomparetext('UTF8Decode', MethodName) = 0 then begin
        try
          result := UTF8Decode(params[0]);
        except
          result := 'FEHLER';
        end;
      end;
    end;
    

    Converting UTF-8-Text in the report:
    [UTF8Decode(<IBXQuery1."TITLE">)]
    

    Thanks to Bj?¶rn for this post: http://www.entwickler-ecke.de/topic_Unicod...rt_65744,0.html

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.