1

I am creating a new application and I need to reuse data from the old one. The old one using Firebird as database and Delphi.

The problem is, inside the Firebird database there is a column which contains strange characters. For example:

{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Arial
Narrow;}{\f1\fnil\fcharset0 MS Sans
Serif;}}\viewkind4\uc1\pard\lang1033\f0\fs18 11.0 - 16.5\f1\fs16\par}

in the application it is displayed as

11.0 - 16.5

and

{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Arial
Narrow;}{\f1\fnil\fcharset0 MS Sans
Serif;}}\viewkind4\uc1\pard\lang1033\f0\fs18 3.500 -
10.000\f1\fs16\par}

in application it is displayed as

3.500 - 10.000

I do not know why the previous developer store the data this way,

How can I pick the string / character that I need, without manually editing the database?

bluish
  • 26,356
  • 27
  • 122
  • 180
stacheldraht27
  • 392
  • 1
  • 6
  • 26
  • 3
    It is the so called RTF format. You can read it as string and load e.g. to a `TRichEdit` control and read it as plain text, but to get just the value you will need a parser. – TLama Sep 22 '15 at 07:50
  • 3
    There is also the data aware [TDBRichEdit](http://docwiki.embarcadero.com/Libraries/XE8/en/Vcl.DBCtrls.TDBRichEdit) – mjn Sep 22 '15 at 07:55
  • Also see: http://stackoverflow.com/questions/188545/regular-expression-for-extracting-text-from-an-rtf-string – GabrielF Sep 23 '15 at 02:47
  • @TLama ,your answer is good, but it would be better if you include rtf format to plain text. ill happy to give mark on your answer^^ – stacheldraht27 Sep 25 '15 at 01:03
  • 1
    Related: http://stackoverflow.com/questions/595865/get-plain-text-from-an-rtf-text, http://stackoverflow.com/questions/29841579/how-to-extract-plain-text-from-rtf-string-using-firebird-sql, http://stackoverflow.com/questions/3227899/using-trichedit-at-runtime-without-defining-a-parent, http://stackoverflow.com/questions/3214281/delphi-best-way-to-convert-rtf-to-text – Mark Rotteveel Sep 27 '15 at 08:20

0 Answers0