Hi Klaus,
May be you are running in the problem, that windows uses different
codepages on command line window and in GUI applications. I've the
experience, that the easiest way is to
1) find out the format of anything wat you get and convert it into perl
internal format. Equal what it is. Content of files, results of database
queries, ...
2) convert any output into the format which is required.

I would try something like this:

################

use Win32::TieRegistry;
use Unicode::String qw(latin1 utf8);
use encoding 'ISO-8859-1';
use Encode qw( decode encode );

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

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

$string = latin1("");
$string->append("Acentuación");

# convert the string to perl internal caracter set:
my $norm_string=decode('latin1',$string->latin1);

# print the string with current codepage for cmd window:
print encode(DosCodepage (),$norm_string);

# create a text file with windows default codepage and view it:
open FH,">c:\\temp\\myfile.txt" or die "Unable to open file";
print FH encode(WinCodepage (),$norm_string);
close FH;
system "notepad c:\\temp\\myfile.txt";

#################

I did no test. but you will see what I mean.
If you ave troubble to make it running on Windows and UNIX, send a
additional message.

Bye
Torsten



                                                                                
                                                 
                    "Klaus Gerber"                                              
                                                 
                    <[EMAIL PROTECTED]>                 To:     
[email protected]                         
                    Sent by:                                 cc:                
                                                 
                    [EMAIL PROTECTED]        Subject:     Problems with 
Encoding                                 
                    eState.com                                                  
                                                 
                                                                                
                                                 
                                                                                
                                                 
                    12.04.2006 23:34                                            
                                                 
                                                                                
                                                 
                                                                                
                                                 






I have problem running a Perl Script under ActivePerl.  On Linux i
have no problem, but with ActivePerl on Windows i have a problem with
the encoding.

use Unicode::String qw(latin1 utf8);
use encoding 'ISO-8859-1';

$string = latin1("");
$string->append("Acentuación");

print $string->latin1;

I get... Acentuaci<n as a response and i can't find what the problem
is, or how to set the default output encoding.

Thanks.


_______________________________________________
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