How to support unicode for multiline text

General TRichView support forum. Please post your questions here
Post Reply
uniandy
Posts: 12
Joined: Thu Oct 12, 2006 4:27 am

How to support unicode for multiline text

Post by uniandy »

Hi Sergey-

Do you have any updates for the exampe:
http://www.trichview.com/support/files/script2.zip

in the main unit, you said:
- supporting Unicode text (some modifications in InsertMultilineText are Not implemented

I tried your example, and it really cannot support multi text unicode, this is the snapshot:

Image

the A part is the original 2-line text and the B part is the result, I tried to solve the problem but haven't find any solution so far, do you have any better solutions on how to change InsertMultilineText menthod to support unicode for multiline text?
uniandy
Posts: 12
Joined: Thu Oct 12, 2006 4:27 am

Post by uniandy »

procedure InsertMultilineText(RVData: TCustomRVData; var ItemNo, Pos: Integer; const Value: String);
var
item: TRVTextItemInfo;
s1, s2: String;
sl: TStringList;
i: Integer;
begin
if Value='' then exit;
s1 := RVData.GetItemTextA(ItemNo);
s2 := Copy(s1, Pos, Length(s1));
s1 := Copy(s1, 1, Pos-1);
sl := TStringList.Create;
sl.Text := Value;
// workaround - TStringList ignores the last cr lf
if (Length(Value)>1) and (Value[Length(Value)-1]=#13) and (Value[Length(Value)]=#10) then
sl.Add('');
// end of workaround
if sl.Count=1 then begin // if it's a single line, then do this
RVData.SetItemTextA(ItemNo, s1+Value+s2);
sl.Free;
inc(Pos, Length(Value)-1);
exit; // exit when this is done
end;
RVData.SetItemTextA(ItemNo, s1+sl[0]);

// for multi-line, maybe this is whether the non-unicode is caused
for i := 1 to sl.Count-1 do begin
item := RichViewTextItemClass.Create(RVData);
s1 := sl;
if i=sl.Count-1 then s1 := s1+s2;
item.StyleNo := RVData.GetItemStyle(ItemNo);
item.ParaNo := RVData.GetItemPara(ItemNo);
item.Inserting(RVData, s1, False);
RVData.Items.InsertObject(ItemNo+i, s1, item);
item.Inserted(RVData, ItemNo+i);
end;

ItemNo := ItemNo+sl.Count-1;
Pos := Length(sl[sl.Count-1])+1;
sl.Free;
end;
uniandy
Posts: 12
Joined: Thu Oct 12, 2006 4:27 am

Post by uniandy »

Hi,Sergey-

Can you help me to solve this problem? I cannot find any solution on this...

Many thanks
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I'll modify this example later this week.
uniandy
Posts: 12
Joined: Thu Oct 12, 2006 4:27 am

Post by uniandy »

Ha, it's been a long time from last visit from this community. it's so happy that I can visit this site again use a Germany web agent. :D
uniandy
Posts: 12
Joined: Thu Oct 12, 2006 4:27 am

Post by uniandy »

Hi,Sergey-

Any updates for this functionality?

best wishes
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Oops, sorry.
Done. Not only modifications to support Unicode in this demo, but also a completely Unicode version.
See here: http://www.trichview.com/forums/viewtopic.php?t=9#5883
uniandy
Posts: 12
Joined: Thu Oct 12, 2006 4:27 am

Post by uniandy »

Sergey-

Thanks a lot, you are great and cool!

This is perfect !!!
Post Reply