Character encoding issues
This is a multi-part message in MIME format.
--============== 81912249==
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16608" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DVerdana color=3D#000080 size=3D2><SPAN =
class=3D626125520-27032008>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.</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana color=3D#000080 size=3D2><SPAN
class=3D626125520-27032008></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana color=3D#000080 size=3D2><SPAN =
class=3D626125520-27032008>Any
ideas about how to make sure that a console application treats =
information from
active directory calls/windows apis correctly?</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana color=3D#000080 size=3D2><SPAN
class=3D626125520-27032008></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana color=3D#000080 size=3D2><SPAN =
class=3D626125520-27032008>Best
regards,</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana color=3D#000080 size=3D2><SPAN
class=3D626125520-27032008></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana color=3D#000080 size=3D2><SPAN
class=3D626125520-27032008>Tev</SPAN></FONT></DIV></BODY></HTML>
------=_NextPart_000_01EA_01C89056.69C7D430--
--============== 81912249==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--============== 81912249==--
Re: Character encoding issues
This is a multi-part message in MIME format.
--============== 04418443==
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
> 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
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)
Content-type: text/html; charset=us-ascii
Content-transfer-encoding: 7BIT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Tevfik Karagülle wrote:
<blockquote cite="mid01e901c8904e$08036c30$6601a8c0 [at] itefixb" type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta content="MSHTML 6.00.6000.16608" name="GENERATOR">
<div><font color="#330033" face="Courier New, Courier, monospace"
size="2"><span class="626125520-27032008">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.</span></font></div>
<div><font color="#330033" face="Courier New, Courier, monospace"
size="2"><span class="626125520-27032008"></span></font><font
color="#330033" face="Courier New, Courier, monospace"> </font></div>
<div><font color="#330033" face="Courier New, Courier, monospace"
size="2"><span class="626125520-27032008">Any ideas about how to make
sure that a console application treats information from active
directory calls/windows apis correctly?</span></font></div>
<div><font color="#330033" face="Courier New, Courier, monospace"
size="2"><span class="626125520-27032008"></span></font><font
color="#330033" face="Courier New, Courier, monospace"> </font></div>
<div><font color="#330033" face="Courier New, Courier, monospace"
size="2"><span class="626125520-27032008">Best regards,</span></font></div>
<div><font color="#330033" face="Courier New, Courier, monospace"
size="2"><span class="626125520-27032008"></span></font><font
color="#330033" face="Courier New, Courier, monospace"> </font></div>
<div><font color="#330033" face="Courier New, Courier, monospace"
size="2"><span class="626125520-27032008">Tev</span></font></div>
</blockquote>
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.<br>
<br>
I also added the following to my standard code:<br>
`chcp 65001`; # change the dos window code page to display correctly
(This helps a bit)<br>
use open ':utf8';<br>
binmode(STDOUT, "utf8");<br>
<br>
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.<br>
<br>
</body>
</html>
--Boundary_(ID_+AmX62LuKWlvMHHpSZo30A)--
--============== 04418443==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--============== 04418443==--
Re: Character encoding issues
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 |
| | <tevfik [at] itefix.no> |
| | Sent by: |
| | activeperl-bounces [at] listserv.Acti|
| | veState.com |
| | |
| | |
| | 27.03.2008 22:03 |
| | |
|---------+------------------------------------------->
>----------------------------------------------------------- -------------=
------------------------------------------------|
| =
|
| To: <activeperl [at] listserv.ActiveState.com> =
|
| 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 [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs