What is the safe way to work with Tricheedit Database?

Asked

Viewed 187 times

0

I’m asking this question because for days I’m having a huge pain in the ass with this junk from Richedit, time he saves right time he saves a lot of ??????????????????????? at the base... I know it may be error in character conversion but the detail is that the problem is intermittent.

If this is the first time you record it correctly

If it’s editing it records a bunch of weird characters, like Chinese.

If I clear the base and insert the text again and save correctly.

Sometimes in editing it records correctly.

I would like to exchange everything for HTML but it is unviable, are years of recording everything in Richedit, because I need the formatted text.

The way I’m doing goes below:

  ...
  fdm.RichStream := TStringStream.Create(fdm.zqrAux_Aet_TextoDiversas.AsAnsiString);
  //fdm.zqrAux_Aet_TextoDiversas.SaveToStream(fdm.RichStream);

  f_richedit := Tf_richedit.Create(nil);
  fdm.RichStream.Position := 0;
  f_richedit.RichEdit.Lines.LoadFromStream(fdm.RichStream);
  TFuncoes.pJustRichEdit(f_richedit.RichEdit, False);
  f_richedit.ShowModal;

  if (fdm.Salvar) then
  begin
    fdm.zqrAux_Aet_Texto.Edit;
    fdm.RichStream.Position := 0;
    fdm.zqrAux_Aet_TextoDiversas.LoadFromStream(fdm.RichStream);//AsString := fdm.RichStream.DataString;
    fdm.zqrAux_Aet_Texto.Post;
    fdm.zConecta.Commit;
  end;
  FreeAndNil(fdm.RichStream); // .Free;
  fdm.zqrAux_Aet_Texto.Close;
  f_richedit := nil;

Note in some "commented" that I have tried saving in other ways, but the problem remains

The database is postgresql, but I think that’s not even the case, because it saves text there and this with UTF8 and everything as the costume asks

Someone knows a sure way to work with this Richedit?

I say safe because correct no longer know, rs

  • fdm.Salvar is a method or just a boolean variable? fdm.RichStream and not what is formatted in f_richedit.RichEdit

  • I believe you already solved your problem, but I went through the same problem. Firebird Database, had a Blob subtype field 1 segment size 5. . Solution: Switch to blob subtype 0 segment size 80; Options and field definitions Blob MEMO as blob subtype 1 segment size 5; FIGURE as blob subtype 0 segment size 50; TEXT as blob subtype 0 segment size 80; we use MEMO for small text, in an environment of 10MB of characters. we use FIGURE to store image-only images. we use TEXT for text editor files at

1 answer

0

It would not be right to record the contents of f_richedit.RichEdit??

  fdm.RichStream := TStringStream.Create(fdm.zqrAux_Aet_TextoDiversas.AsAnsiString);
  //fdm.zqrAux_Aet_TextoDiversas.SaveToStream(fdm.RichStream);

  f_richedit := Tf_richedit.Create(nil);
  fdm.RichStream.Position := 0;
  f_richedit.RichEdit.Lines.LoadFromStream(fdm.RichStream);
  TFuncoes.pJustRichEdit(f_richedit.RichEdit, False);
  f_richedit.ShowModal;

  if (fdm.Salvar) then
  begin
    fdm.zqrAux_Aet_Texto.Edit;
    fdm.RichStream.Position := 0;
    fdm.zqrAux_Aet_TextoDiversas.AsString := f_richedit.RichEdit.Lines.Text;
    fdm.zqrAux_Aet_Texto.Post;
    fdm.zConecta.Commit;
  end;
  FreeAndNil(fdm.RichStream); // .Free;
  fdm.zqrAux_Aet_Texto.Close;
  f_richedit := nil;

Edited

I don’t know if you’ve tried but try to do so, you save in Stream, format the text in richedit and then save again in the stream before saving in BD. When displaying text where you want, use Loadfromfile.

Note: Leave richedit’s Plaintext property as False.

  //fdm.RichStream := TStringStream.Create(fdm.zqrAux_Aet_TextoDiversas.AsAnsiString);
  fdm.zqrAux_Aet_TextoDiversas.SaveToStream(fdm.RichStream);

  f_richedit := Tf_richedit.Create(nil);
  fdm.RichStream.Position := 0;
  f_richedit.RichEdit.Lines.LoadFromStream(fdm.RichStream);
  TFuncoes.pJustRichEdit(f_richedit.RichEdit, False);
  f_richedit.ShowModal;

  {Colocar aqui a função para limpar o fdm.RichStream aqui antes de salvar novamente, não lembro como é}
  f_richedit.RichEdit.Lines.SaveToStream(fdm.RichStream);

  if(fdm.Salvar)then
  begin
    fdm.zqrAux_Aet_Texto.Edit;
    fdm.RichStream.Position := 0;
    fdm.zqrAux_Aet_TextoDiversas.LoadFromStream(fdm.RichStream);//AsString := fdm.RichStream.DataString;
    fdm.zqrAux_Aet_Texto.Post;
    fdm.zConecta.Commit;
  end;

  fdm.zqrAux_Aet_Texto.Close;
  FreeAndNil(fdm.RichStream); // .Free;
  FreeAndNil(f_richedit);
  • If you save the Line.Text it saves the text without formatting

  • Then just try f_richedit.RichEdit.Text and mark richedit Plaintext as False

  • Yeah, I tried... he brings the plain text... I also thought of that possibility

  • One more time, try f_richedit.RichEdit.SavetoStream(oSuaStream) and then do as you were doing fdm.zqrAux_Aet_TextoDiversas.LoadFromStream(fdm.RichStream);

  • So Matheus, I’ve already done this if you look at the commented line, but the error continues... you know when you get no floor... the company working and the error persisting... I would trade everything for html, because it can work better with webbrowser, but there are already several hundred thousand budgets made like this... I will have to make an application to make this correction... and even so I run the risk of having problems in the conversion, because many texts came from word... and this blessed word fills the text with garbage.

  • I understand, some mistakes sometimes as "simple" as they are, make us lose days... Check the edition of my answer.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.