mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-06 12:18:28 +02:00
compiler: fix tstringconstnode.changestringtype() for case of unicode to ansi conversion. remove hackish and incorrect change of ansistring def
git-svn-id: trunk@19461 -
This commit is contained in:
parent
1404b7397a
commit
6ec879219e
@ -1002,26 +1002,24 @@ implementation
|
|||||||
if (cst_type in [cst_widestring,cst_unicodestring]) and
|
if (cst_type in [cst_widestring,cst_unicodestring]) and
|
||||||
not(tstringdef(def).stringtype in [st_widestring,st_unicodestring]) then
|
not(tstringdef(def).stringtype in [st_widestring,st_unicodestring]) then
|
||||||
begin
|
begin
|
||||||
if (tstringdef(def).encoding=CP_UTF8) or
|
cp1:=tstringdef(def).encoding;
|
||||||
(current_settings.sourcecodepage=CP_UTF8) then
|
if (cp1=CP_NONE) or (cp1=0) then
|
||||||
|
cp1:=current_settings.sourcecodepage;
|
||||||
|
if (cp1=CP_UTF8) then
|
||||||
begin
|
begin
|
||||||
pw:=pcompilerwidestring(value_str);
|
pw:=pcompilerwidestring(value_str);
|
||||||
l:=(getlengthwidestring(pw)*4)+1;
|
l:=UnicodeToUtf8(nil,PUnicodeChar(pw^.data),0);
|
||||||
getmem(pc,l);
|
getmem(pc,l);
|
||||||
l2:=UnicodeToUtf8(pc,l,PUnicodeChar(pw^.data),getlengthwidestring(pw));
|
UnicodeToUtf8(pc,l,PUnicodeChar(pw^.data),getlengthwidestring(pw));
|
||||||
if (l<>l2) then
|
len:=l-1;
|
||||||
ReAllocMem(pc,l2);
|
|
||||||
len:=l2-1;
|
|
||||||
donewidestring(pw);
|
donewidestring(pw);
|
||||||
value_str:=pc;
|
value_str:=pc;
|
||||||
if (tstringdef(def).encoding<>CP_UTF8) then
|
|
||||||
tstringdef(def).encoding:=CP_UTF8;
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
pw:=pcompilerwidestring(value_str);
|
pw:=pcompilerwidestring(value_str);
|
||||||
getmem(pc,getlengthwidestring(pw)+1);
|
getmem(pc,getlengthwidestring(pw)+1);
|
||||||
unicode2ascii(pw,pc,tstringdef(def).encoding);
|
unicode2ascii(pw,pc,cp1);
|
||||||
donewidestring(pw);
|
donewidestring(pw);
|
||||||
value_str:=pc;
|
value_str:=pc;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user