Hola!
I have a problem, the following code is part of Subtitle Workshop in which to add a Tag string in a TMemo, apparently it works correctly but with Chinese text for example this add a question mark and duplicate some text after that, which is wrong ?
procedure SetTextTag(const Tag: String);
var
Memo : TMemo;
i : Integer;
s1, s2 : String;
begin
Memo := GetMemoFocused;
if Memo = NIL then Exit;
i := Memo.SelStart;
s1 := Copy(Memo.Text, 1, Memo.SelStart);
if Memo.SelText <> '' then
s2 := Copy(Memo.Text, Memo.SelStart+Memo.SelLength+1, Length(Memo.Text)-(Memo.SelStart+Memo.SelLength))
else
s2 := Copy(Memo.Text, Memo.SelStart+1, Length(Memo.Text)-Memo.SelStart);
Memo.Text := Format('%s{\%s1}%s{\%s0}%s', [s1, Tag, Memo.SelText, Tag, s2]);
end;
Thanks in advance!