Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3340450
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:36:33+00:00 2026-05-18T00:36:33+00:00

I am currently in the process of migrating our software solution from Delphi 7

  • 0

I am currently in the process of migrating our software solution from Delphi 7 to 2010. Mostly the changes have been simple and there are only a small amount of hurdles left to go.

On a form we use a TRichEdit which displayed rtf text grabbed from a blob field in a MSSQL db. This is how it worked in Delphi 7:

//Get RTF text from Blob field using TADOQuery
rtfStream := sql.CreateBlobStream(sql.FieldByName('rtftext'), BmRead) as TMemoryStream;

//Load into TRichEdit
RichEdit.PlainText := False;
RichEdit.Lines.LoadFromStream(rtfStream);

This would display the RTF as expected in the TRichEdit component, but the same code in Delphi 2010 displays the RTF as plain text with tabs between each character. I assume this has a lot to do with the change from Ansi to Unicode, but I haven’t had any luck rectifying the problem.

Any help getting this to work would be much appreciated. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:36:33+00:00Added an answer on May 18, 2026 at 12:36 am

    Okay I figured it out.

    For loading the rtf text:

    //Get the data from the database as AnsiString
    rtfString := sql.FieldByName('rtftext').AsAnsiString;
    
    //Write the string into a stream
    stream := TMemoryStream.Create;
    stream.Clear;
    stream.Write(PAnsiChar(rtfString)^, Length(rtfString));
    stream.Position := 0;
    
    //Load the stream into the RichEdit
    RichEdit.PlainText := False;
    RichEdit.Lines.LoadFromStream(stream);
    
    stream.Free;
    

    For saving the rtf text:

    //Save to stream
    stream := TMemoryStream.Create;
    stream.Clear;
    
    RichEdit.Lines.SaveToStream(stream);
    stream.Position := 0;
    
    //Read from the stream into an AnsiString (rtfString)
    if (stream.Size > 0) then begin
        SetLength(rtfString, stream.Size);
        if (stream.Read(rtfString[1], stream.Size) <= 0) then
            raise EStreamError.CreateFmt('End of stream reached with %d bytes left to read.', [stream.Size]);
    end;
    
    stream.Free;
    
    //Save to database
    sql.FieldByName('rtftext').AsAnsiString := rtfString;
    

    This took me way too long to figure out 🙂 I guess I have learned one thing though… if something goes wrong in Delphi 2010, its usually related to unicode 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are currently in the process of migrating our application from our production environment
We are in the process of migrating our bug tracking to Bugzilla from a
We are currently in the process of refactoring our site and we have decided
I am currently in the process of creating my own blog and I have
I am currently trying to automate the deployment process of our rails app as
I am currently in the process of writing some software in Java that I
I'm currently writing a process that generates Powerpoint reports programmatically from a given template
I'm currently in the process of setting up a continuous integration environment at work.
We're currently in the process of setting up a source control/build/and more-server for .NET
I am currently in the process of restructuring my local Subversion repository by adding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.