procmail log chinese subject [2]

procmail log chinese subject [2]

am 03.10.2005 13:12:10 von Andrzej Adam Filip

You can use the perl script below to convert subjects in procmail log file
into your preferred encoding.

Usage:
perl script_name < procmail_log_file_ascii > procmail_log_file_utf8

1) The script below converts subjects into UTF-8 encoding (most general).
You can choose another output file encoding as shown in commented out line
for ISO-8859-2.

2) The script requires some improvements to deal correctly with truncated
subjects (procmail cuts too long subject).

------------------------------------------------------------ ------------
#!/usr/bin/perl
use utf8;
use Encode qw/decode/;

# Set encoding of STDOUT
# binmode(STDOUT,':encoding(ISO-8859-2)') or die $@;
binmode(STDOUT,':utf8') or die;

while(){
if( /^ Subject:/oi ) {
$_=decode('MIME-Header',$_);
}
print;
}

--
Andrzej [en:Andrew] Adam Filip anfi@priv.onet.pl anfi@xl.wp.pl
All that is necessary for the triumph of evil is that good men do nothing
-- Edmund Burke (1729-1797)