mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-01 13:11:06 +02:00
* handle rawbytestrings in Win32Ansi2UnicodeMove properly, resolves #38299
git-svn-id: trunk@48021 -
This commit is contained in:
parent
f2568e37e4
commit
7d5b0d2382
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -18631,6 +18631,7 @@ tests/webtbs/tw38267b.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw3827.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3829.pp svneol=native#text/plain
|
||||
tests/webtbs/tw38295.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw38299.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw3833.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3840.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3841.pp svneol=native#text/plain
|
||||
|
@ -609,6 +609,14 @@ procedure Win32Ansi2UnicodeMove(source:pchar;cp : TSystemCodePage;var dest:Unico
|
||||
dwFlags:=MB_PRECOMPOSED;
|
||||
end;
|
||||
destlen:=MultiByteToWideChar(cp, dwFlags, source, len, nil, 0);
|
||||
{ destlen=0 means that Windows cannot convert, so call the default
|
||||
handler. This is similiar to what unix does and is a good fallback
|
||||
if rawbyte strings are passed }
|
||||
if destlen=0 then
|
||||
begin
|
||||
DefaultAnsi2UnicodeMove(source,DefaultSystemCodePage,dest,len);
|
||||
exit;
|
||||
end;
|
||||
// this will null-terminate
|
||||
setlength(dest, destlen);
|
||||
if destlen>0 then
|
||||
|
15
tests/webtbs/tw38299.pp
Normal file
15
tests/webtbs/tw38299.pp
Normal file
@ -0,0 +1,15 @@
|
||||
{ %opt=-O2 -Fcutf8 }
|
||||
program bug;
|
||||
const
|
||||
cAnsiLineFeed = AnsiChar(#10);
|
||||
cAnsiCarriageReturn = AnsiChar(#13);
|
||||
var
|
||||
test: RawByteString;
|
||||
begin
|
||||
test := '123';
|
||||
test := test + UTF8Encode('456') + '789' + cAnsiCarriageReturn + cAnsiLineFeed;
|
||||
writeln(test);
|
||||
if test<>'123456789'#13#10 then
|
||||
halt(1);
|
||||
writeln('ok');
|
||||
end.
|
Loading…
Reference in New Issue
Block a user