trichview.com

trichview.support




Re: unicode encoding


Return to index


Author

Message

Sergey Tkachenko

Posted: 02/03/2005 23:57:38


Something like this:


function LoadRVFFromField(rv: TCustomRichView; tbl: TDataSet;

                          const FieldName: String): Boolean;

var Stream: TStream;

begin

  Stream := tbl.CreateBlobStream(tbl.FieldByName(FieldName), bmRead);

  try

    Result := rv.LoadRVFFromStream(Stream);

  finally

    Stream.Free;

  end;

  rv.Format;

end;


procedure SaveTextToField(const s: String; tbl: TDataSet;

                          const FieldName: String);

begin

  table.Edit;

  Stream := tbl.CreateBlobStream(tbl.FieldByName(FieldName), bmWrite);

  Stream.WriteBuffer(PChar(s)^, Length(s));

  delete Stream;

  table.Post;

end;



table.First;

while not table.Eof do

begin

  LoadRVFFromField(rv, table, 'french');

  // GetAllText() is defined in the unit RVGetTextW.

  // Do not use here the function with the same name

  // from RVGetText unit!

  SaveTextToField(RVEncodeWidestring(RVGetTextW.GetAllText(rv)),

    table, 'frenchUTF');

  table.Next;

end;


I did not test this code, but it's simple.

Of course, back up your database before running.

And, as I said before, if you use it for text indexing purposes, I recommend

to modify RVEncodeWidestring so that it will not change spaces and

punctuations, otherwise all text will be treated as one long word.


> If I have field 'french' which is populated (~84 000 records) in my

> paradox 7 table delphi5 and I have also created a field 'frenchUTF'

> which is currently empty, how would I use function RVEncodeWidestriing

> to popluate field 'frenchUTF' using field 'french' as the source and

> field 'frenchUTF' as the target.

>

> eg

>

> field.'french'.[bonjour] >>>

> field.'frenchUTF'.[0062006F006E006A006F00750072]

> and do this for all 84000 entries.

>

> ay hellp is appreciated

>

> Richard

>





Powered by ABC Amber Outlook Express Converter