mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 13:29:14 +02:00
* translate placeholder code page numbers into actual code pages in
fpc_ansistr_to_widechararray(), so that CP_ACP/CP_OEM etc are properly handled (fixes assign/assignfile with non-ansi characters in source files that don't explicitly specify the code page) git-svn-id: trunk@29218 -
This commit is contained in:
parent
3e24a9ebfd
commit
cec82a1540
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -11414,6 +11414,7 @@ tests/test/tcpstr8.pp svneol=native#text/pascal
|
|||||||
tests/test/tcpstr9.pp svneol=native#text/pascal
|
tests/test/tcpstr9.pp svneol=native#text/pascal
|
||||||
tests/test/tcpstransistr2shortstring.pp svneol=native#text/plain
|
tests/test/tcpstransistr2shortstring.pp svneol=native#text/plain
|
||||||
tests/test/tcpstransistr2widechararray.pp svneol=native#text/plain
|
tests/test/tcpstransistr2widechararray.pp svneol=native#text/plain
|
||||||
|
tests/test/tcpstransistr2widechararray2.pp svneol=native#text/plain
|
||||||
tests/test/tcpstransistrcompare.pp svneol=native#text/plain
|
tests/test/tcpstransistrcompare.pp svneol=native#text/plain
|
||||||
tests/test/tcpstransistrcompareequal.pp svneol=native#text/plain
|
tests/test/tcpstransistrcompareequal.pp svneol=native#text/plain
|
||||||
tests/test/tcpstransistrcopy.pp svneol=native#text/plain
|
tests/test/tcpstransistrcopy.pp svneol=native#text/plain
|
||||||
|
@ -817,7 +817,7 @@ begin
|
|||||||
len := length(src);
|
len := length(src);
|
||||||
{ make sure we don't dereference src if it can be nil (JM) }
|
{ make sure we don't dereference src if it can be nil (JM) }
|
||||||
if len > 0 then
|
if len > 0 then
|
||||||
widestringmanager.ansi2widemoveproc(pchar(@src[1]),StringCodePage(src),temp,len);
|
widestringmanager.ansi2widemoveproc(pchar(@src[1]),TranslatePlaceholderCP(StringCodePage(src)),temp,len);
|
||||||
len := length(temp);
|
len := length(temp);
|
||||||
if len > length(res) then
|
if len > length(res) then
|
||||||
len := length(res);
|
len := length(res);
|
||||||
|
31
tests/test/tcpstransistr2widechararray2.pp
Normal file
31
tests/test/tcpstransistr2widechararray2.pp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{ this file is stored in utf8, but we don't tell the compiler so that the string
|
||||||
|
constant gets code page 0/CP_ACP; this test is to make sure that
|
||||||
|
fpc_ansistr_to_widechararray() translates CP_ACP to the actual value of
|
||||||
|
DefaultSystemCodePage before calling widestringmanager.ansi2widemoveproc
|
||||||
|
}
|
||||||
|
|
||||||
|
{$ifdef unix}
|
||||||
|
uses
|
||||||
|
cwstring;
|
||||||
|
{$endif}
|
||||||
|
{$r+}
|
||||||
|
var
|
||||||
|
u8: ansistring;
|
||||||
|
a: array[0..10] of unicodechar;
|
||||||
|
u16: unicodestring;
|
||||||
|
i: longint;
|
||||||
|
begin
|
||||||
|
DefaultSystemCodePage:=CP_UTF8;
|
||||||
|
u8:='èà';
|
||||||
|
a:=u8;
|
||||||
|
u16:=unicodestring(u8);
|
||||||
|
for i:=0 to 1 do
|
||||||
|
begin
|
||||||
|
writeln('u16[',i-low(a)+low(u16),'] = $',hexstr(ord(u16[i-low(a)+low(u16)]),2));
|
||||||
|
writeln('a[',i,'] = $',hexstr(ord(a[i]),2));
|
||||||
|
if u16[i-low(a)+low(u16)]<>a[i] then
|
||||||
|
halt(i+1);
|
||||||
|
end;
|
||||||
|
if a[2]<>#0 then
|
||||||
|
halt(3);
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user