Does somebody know the reason why CharUpper and CharUpperW declaration in Delphi 10.3 is different than in Delphi 10.4.
Correct declaration in Delphi 10.3
var
chr :WideChar;
begin
chr := WideChar(CharUpperW(PWideChar('a'))); //chr = 'A'
// chr := WideChar(CharUpperW(WideChar('a'))); //raise exeption: "access violation...
Correct declaration in Delphi 10.4
var
chr :WideChar;
begin
// chr := WideChar(CharUpperW(PWideChar('a'))); //raise exeption: "access violation...
chr := WideChar(CharUpperW(WideChar('a'))); //chr = 'A'
EDIT: The Remy Lebeau expalanation is right about PWideChar but there is still differences about Delphi version 10.4 and earlier versions!
Lebeau expalanation code sample compile in version 10.4 and earlier versions, but the output of function is different. All versions before 10.4 get correct output "A"!
var
char , chr : WideChar;
begin
chr := 'a';
char := WideChar(CharUpperW(PWideChar(chr)));
end;
This sample under 10.4 doesn't work correct the output is random character.
And of course...
The declaration of function CharUpperW it the same in boath versions of Delphi.
LPWSTR = PWideChar;
function CharUpperW(lpsz: LPWSTR): LPWSTR; stdcall;**
EDIT: added disassembled code under 10.4
umCommon.pas.114: chr := 'a';
0064C52C 66BB6100 mov bx,$0061
umCommon.pas.115: char := WideChar(CharUpperW(PWideChar(chr)));
0064C530 8D45FC lea eax,[ebp-$04]
0064C533 8BD3 mov edx,ebx
0064C535 E8EEE7DBFF call @UStrFromWChar
0064C53A 8B45FC mov eax,[ebp-$04]
0064C53D E8C2E7DBFF call @UStrToPWChar
0064C542 50 push eax
0064C543 E8809DDCFF call CharUpperW
Disassembled code under 10.3
umCommon.pas.114: chr := 'a';
0063A905 66BB6100 mov bx,$0061
umCommon.pas.115: char := WideChar(CharUpperW(PWideChar(chr)));
0063A909 0FB7C3 movzx eax,bx
0063A90C 50 push eax
0063A90D E8AAB1DDFF call CharUpperW