Re: help for MS-Windows code related to locales for C similar with Perl
> Date: Sat, 18 Jan 2025 13:35:38 +0100 > From: Patrice Dumas > Cc: bug-texinfo@gnu.org > > On Sat, Jan 18, 2025 at 02:18:14PM +0200, Eli Zaretskii wrote: > > > Date: Sat, 18 Jan 2025 12:11:13 +0100 > > > From: Patrice Dumas > > > Cc: Eli Zaretskii > > > > > The header is . 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.) > > It is a failsafe in case $CP could be undefined, looks like this is not > possible in the C function. It is also not needed in C, since GetACP will always yield a codepage number.
Re: help for MS-Windows code related to locales for C similar with Perl
On Sat, Jan 18, 2025 at 02:18:14PM +0200, Eli Zaretskii wrote: > > Date: Sat, 18 Jan 2025 12:11:13 +0100 > > From: Patrice Dumas > > Cc: Eli Zaretskii > > > The header is . 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.) It is a failsafe in case $CP could be undefined, looks like this is not possible in the C function. Thanks! -- Pat
Re: help for MS-Windows code related to locales for C similar with Perl
> Date: Sat, 18 Jan 2025 12:11:13 +0100 > From: Patrice Dumas > Cc: Eli Zaretskii > > 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 . 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.)
help for MS-Windows code related to locales for C similar with Perl
Hello, I texi2any.pl, we have two little bits of MS-Windows specific code related to locales. I would like to have the same in the C texi2any main program implementation. Could you please help me to do that? I would need two information: 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. 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; } } CC'ing Eli who provided this for Perl. Thanks in advance, -- Pat