I use bookmarks to mark some special blocks of unicode text in my documents so I can collect these special bloks of text at any time.
I cant seem to get the selected text as unicode. What should I do.
I use bookmarks to mark some special blocks of unicode text in my documents so I can collect these special bloks of text at any time.
I cant seem to get the selected text as unicode. What should I do.
SaveToStream(aStream, 'UNICODE', true)
would save the selection as unicode text. (Requires latest version)
Julian
Hi,
I tried the SaveToStream(aStream, 'UNICODE', true) but...
...It returns all text and not only selection. Maybee it has something to do with the third boolean parameter, which is not present in my version [5.19]. Should this have been an SelectionOnly boolean?
Additional I have really hard times getting the stream converted to a WideString. Maybe you already have an example of how it can be done, knowing that this is really not an WPTools issue :D
my mistake, use SaveSelectionToStream
Hi
I finally got it to work. I'll post the code here, and maybee other could benefit from it. The only thing left is that when nothing i selected everything is returned by the SaveSelectionToStream. I would say that this is inappropriate. Wouldn't you agree?
var
stmMemory : TMemoryStream;
strKeyword: WideString;
begin
stmMemory := TMemoryStream.Create;
try
strKeyword := '';
rteEditor.SaveSelectionToStream(stmMemory, 'UNICODE');
SetLength(strKeyword, stmMemory.Size div 2);
stmMemory.Position := 0;
stmMemory.ReadBuffer(strKeyword[1], stmMemory.Size);
// do something with strKeyword
finally
stmMemory.Free;
end;
end;
Alles anzeigen
I agree but you can check for
WPRichText.IsSelected