Additional management for text editor selection of partial surrogate pair

This commit is contained in:
Marc Durdin 2017-09-25 12:56:41 +07:00
parent afcdbc6767
commit b9b32fc4cb
2 changed files with 11 additions and 4 deletions

View file

@ -59,7 +59,7 @@ uses
Dialogs, Menus, ImgList,
MenuImgList, ExtCtrls,
{$IFDEF USE_PLUSMEMO}
{IFDEF USE_PLUSMEMO}
SyntaxHighlight,
PlusMemo,
PlusGutter,
@ -67,7 +67,7 @@ uses
HtmlHighlight,
pmprint,
PMSupport,
{$ENDIF}
{ENDIF}
TextFileFormat, UfrmTike,
System.ImageList, KeymanDeveloperMemo,
@ -925,7 +925,9 @@ begin
if ch = '' then Exit;
if Uni_IsSurrogate2(ch[1]) then
ch := memo.GetTextPart(memo.SelStart-2, memo.SelStart);
ch := memo.GetTextPart(memo.SelStart-2, memo.SelStart)
else if Uni_IsSurrogate1(ch[1]) then
ch := memo.GetTextPart(memo.SelStart-1, memo.SelStart+1);
token := FormatUnicode(ch);
end;

View file

@ -325,7 +325,12 @@ procedure TClearTypeDrawCharacter.SelectFallbackFont(Handle: THandle; const Text
var
uc: DWord;
begin
uc := Char.ConvertToUtf32(Text, 0); // I3310
try
uc := Char.ConvertToUtf32(Text, 0); // I3310
except
on E:EArgumentOutOfRangeException do
uc := $FFFD; // Not a character, invalid Unicode
end;
if uc < $10000 then SelectFont(Handle, ctfCode2000)
else if uc < $20000 then SelectFont(Handle, ctfCode2001)
else if uc < $30000 then SelectFont(Handle, ctfCode2002)