mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Get maximum selection with UTF-8
This commit is contained in:
parent
09a518ee7b
commit
492ddd91e4
1 changed files with 12 additions and 1 deletions
|
|
@ -2683,14 +2683,25 @@ begin
|
|||
end;
|
||||
|
||||
function TViewerControl.Selection: String;
|
||||
const
|
||||
MAX_LEN = 1024;
|
||||
var
|
||||
sText: String;
|
||||
ALength: PtrInt;
|
||||
InvalidCharLen: Integer;
|
||||
begin
|
||||
if (FBlockEnd - FBlockBeg) <= 0 then
|
||||
Exit(EmptyStr);
|
||||
ALength:= FBlockEnd - FBlockBeg;
|
||||
if ALength > 256 then ALength:= 256;
|
||||
if ALength > MAX_LEN then
|
||||
begin
|
||||
ALength:= MAX_LEN;
|
||||
if FEncoding in [veUtf8, veUtf8bom] then
|
||||
begin
|
||||
SafeUTF8PrevCharLen(GetDataAdr + FBlockBeg + ALength, 8, InvalidCharLen);
|
||||
Dec(ALength, InvalidCharLen);
|
||||
end;
|
||||
end;
|
||||
SetString(sText, GetDataAdr + FBlockBeg, ALength);
|
||||
Result := ConvertToUTF8(sText);
|
||||
end;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue