diff --git a/windows/src/developer/TIKE/main/UframeTextEditor.pas b/windows/src/developer/TIKE/main/UframeTextEditor.pas index 4c51373740..bf68e2c782 100644 --- a/windows/src/developer/TIKE/main/UframeTextEditor.pas +++ b/windows/src/developer/TIKE/main/UframeTextEditor.pas @@ -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; diff --git a/windows/src/global/delphi/general/CleartypeDrawCharacter.pas b/windows/src/global/delphi/general/CleartypeDrawCharacter.pas index a126c552d7..1e842334b3 100644 --- a/windows/src/global/delphi/general/CleartypeDrawCharacter.pas +++ b/windows/src/global/delphi/general/CleartypeDrawCharacter.pas @@ -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)