> Date: Sat, 18 Jan 2025 12:11:13 +0100
> From: Patrice Dumas <[email protected]>
> Cc: Eli Zaretskii <[email protected]>
>
> 1) what would be the equivalent in C of if ($^O eq 'MSWin32') in Perl?
> My guess is that it is
> # ifdef _WIN32
> but I am not sure.
Yes, you can use _WIN32.
> 2) what would be the Ms-Windows specific parts in the following code
> (to get the CP value) in C (with the needed includes):
>
> eval 'require Win32::API';
> if (!$@) {
> Win32::API::More->Import("kernel32", "int GetACP()");
> my $CP = GetACP();
> if (defined($CP)) {
> $locale_encoding = 'cp'.$CP;
> }
> }
The header is <windows.h>. You don't need to load kernel32.dll or
import GetACP, as this will be taken care of when the program is
linked on Windows. The code is
char locale_encoding[8];
unsigned cp = GetACP ();
locale_encoding = sprintf (locale_encoding, "cp%u", cp);
(I don't know what does "if (defined($CP))" part do in Perl.)