Allow WideChar const to UTF8String const conversion

This commit is contained in:
Sergey Larin 2022-01-28 13:09:52 +03:00 committed by Michael Van Canneyt
parent 4d33e5f137
commit de58691e75

View File

@ -1282,7 +1282,9 @@ implementation
begin
if (torddef(left.resultdef).ordtype=uwidechar) then
begin
if (current_settings.sourcecodepage<>CP_UTF8) then
if not((current_settings.sourcecodepage=CP_UTF8) or
((tstringdef(resultdef).stringtype=st_ansistring) and
(tstringdef(resultdef).encoding=CP_UTF8))) then
begin
if tordconstnode(left).value.uvalue>127 then
begin
@ -1311,6 +1313,13 @@ implementation
l:=UnicodeToUtf8(@(sa[1]),Length(sa),@cw,1);
SetLength(sa,l-1);
hp:=cstringconstnode.createstr(sa);
{ explicitly set the type of string constant to avoid unnecessary conversion }
if (tstringdef(resultdef).stringtype=st_ansistring) and
(tstringdef(resultdef).encoding=CP_UTF8) then
begin
hp.cst_type:=cst_ansistring;
hp.resultdef:=resultdef;
end;
end
end
else