Hi,
here are 2 small procedures, working for users without administrative
privilegies as well:

###################
use if ($^O eq 'MSWin32'), "Win32::TieRegistry";

my $Registry={};
if ($^O eq 'MSWin32') {
      $Registry=$Win32::TieRegistry::Registry->Open(
            "",
            {
                  Access=>Win32::TieRegistry::KEY_READ(),
                  Delimiter=>"\\"
            }
      );  # needed for users which are not administrators
}

sub WinCodepage ()
{
      my
$cp=$Registry->{"LMachine\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\\\ACP"};
      $cp="1252"  unless (defined $cp);
      return sprintf('cp%s',$cp);
}

sub CmdCodepage ()
{
      my
$cp=$Registry->{"LMachine\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\\\OEMCP"};
      $cp="850" unless (defined $cp) ;
      return sprintf('cp%s',$cp);
}
#####################

Now you may open input by

open IN,sprintf('<:encoding(%s)',CmdCodepage()),$file)

If it is not working, try to use WinCodepage() instead of CmdCodepage().
If you red from STDIN, reopen it with the same method.

Bye
Torsten Werner



|---------+------------------------------------------->
|         |           Tevfik Karagülle                |
|         |           <[EMAIL PROTECTED]>              |
|         |           Sent by:                        |
|         |           [EMAIL PROTECTED]|
|         |           veState.com                     |
|         |                                           |
|         |                                           |
|         |           27.03.2008 22:03                |
|         |                                           |
|---------+------------------------------------------->
  
>------------------------------------------------------------------------------------------------------------------------|
  |                                                                             
                                           |
  |        To:      <[email protected]>                       
                                           |
  |        cc:                                                                  
                                           |
  |        Subject: Character encoding issues                                   
                                           |
  
>------------------------------------------------------------------------------------------------------------------------|




I have a couple of console mode perl scripts processing information from
Active Directory fields and group names from windows APIs. I observe odd
output when those information contains special/foreign characters.

Any ideas about how to make sure that a console application treats
information from active directory calls/windows apis correctly?

Best regards,

Tev_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to