Character encoding issues

Character encoding issues

am 27.03.2008 22:03:38 von tevfik

This is a multi-part message in MIME format.

--===============2081912249==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_01EA_01C89056.69C7D430"

This is a multi-part message in MIME format.

------=_NextPart_000_01EA_01C89056.69C7D430
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

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

------=_NextPart_000_01EA_01C89056.69C7D430
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable



charset=3Diso-8859-1">


class=3D626125520-27032008>I=20
have a couple of console mode perl scripts processing information =
from=20
Active Directory fields and group names from windows APIs. I observe odd =
output=20
when those information contains special/foreign =
characters.

class=3D626125520-27032008> 

class=3D626125520-27032008>Any=20
ideas about how to make sure that a console application treats =
information from=20
active directory calls/windows apis correctly?

class=3D626125520-27032008> 

class=3D626125520-27032008>Best=20
regards,

class=3D626125520-27032008> 

class=3D626125520-27032008>Tev


------=_NextPart_000_01EA_01C89056.69C7D430--


--===============2081912249==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============2081912249==--

Re: Character encoding issues

am 27.03.2008 23:39:29 von bdaoust

This is a multi-part message in MIME format.

--===============2004418443==
Content-type: multipart/alternative;
boundary="Boundary_(ID_+AmX62LuKWlvMHHpSZo30A)"

This is a multi-part message in MIME format.

--Boundary_(ID_+AmX62LuKWlvMHHpSZo30A)
Content-type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Tevfik Karagülle wrote:

> I have a couple of console mode perl scripts processing information=20
> from Active Directory fields and group names from windows APIs. I=20
> observe odd output when those information contains special/foreign=20
> characters.
> =20
> Any ideas about how to make sure that a console application treats=20
> information from active directory calls/windows apis correctly?
> =20
> Best regards,
> =20
> Tev

I've had toubles with that as well, but it seems to work best for me,=20
when I send output to a file, then open the file in notepad or something.

I also added the following to my standard code:
`chcp 65001`; # change the dos window code page to display correctly=20
(This helps a bit)
use open ':utf8';
binmode(STDOUT, "utf8");

Note: also switch my console font to "Raster Font" as was advised on=20
some windows help page along with using chcp to change the code page. =20
But still the results are best if I send the data to a file then look at =
it.


--Boundary_(ID_+AmX62LuKWlvMHHpSZo30A)
Content-type: text/html; charset=us-ascii
Content-transfer-encoding: 7BIT








Tevfik Karagülle wrote:




size="2">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.

size="2"> color="#330033" face="Courier New, Courier, monospace"> 

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

size="2"> color="#330033" face="Courier New, Courier, monospace"> 

size="2">Best regards,

size="2"> color="#330033" face="Courier New, Courier, monospace"> 

size="2">Tev


I've had toubles with that as well, but it seems to work best for me,
when I send output to a file, then open the file in notepad or
something.



I also added the following to my standard code:

`chcp 65001`; # change the dos window code page to display correctly
(This helps a bit)

use open ':utf8';

binmode(STDOUT, "utf8");



Note: also switch my console font to "Raster Font" as was advised on
some windows help page along with using chcp to change the code page. 
But still the results are best if I send the data to a file then look
at it.






--Boundary_(ID_+AmX62LuKWlvMHHpSZo30A)--

--===============2004418443==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============2004418443==--

Re: Character encoding issues

am 28.03.2008 09:44:05 von Torsten.Werner

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

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

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

sub WinCodepage ()
{
my
$cp=3D$Registry->{"LMachine\\SYSTEM\\CurrentControlSet\\Cont rol\\Nls\\CodeP=
age\\\\ACP"};
$cp=3D"1252" unless (defined $cp);
return sprintf('cp%s',$cp);
}

sub CmdCodepage ()
{
my
$cp=3D$Registry->{"LMachine\\SYSTEM\\CurrentControlSet\\Cont rol\\Nls\\CodeP=
age\\\\OEMCP"};
$cp=3D"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 |
| | |
| | Sent by: |
| | activeperl-bounces@listserv.Acti|
| | veState.com |
| | |
| | |
| | 27.03.2008 22:03 |
| | |
|---------+------------------------------------------->
>----------------------------------------------------------- -------------=
------------------------------------------------|
| =
|
| To: =
|
| 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
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs