All pastes #985893 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-04-15 11:47 UTC
rendered paste body
--- senastemail.pl      Thu Jan 18 07:51:02 2007
+++ senastemail2.pl     Tue Apr 15 13:46:46 2008
@@ -201,12 +201,13 @@
 #<!-- name="Daniel Stenberg" -->
 #<!-- email="Daniel.Stenberg@contactor.se" -->
 #<!-- subject="Re: Nyligen publicerat - ska allt finnas där?" -->
+#<!-- charset="UTF-8" -->

 sub parsehtmlfile {
     my ($file) = @_;

     open(FILE, "<$file");
-    my ($date, $name, $email, $subject, $inreplyto);
+    my ($date, $name, $email, $subject, $inreplyto, $charset);
     while(<FILE>) {
         if(/^<!-- isoreceived=\"([^\"]*)\"/) {
             $date = $1;
@@ -223,11 +224,23 @@
         elsif(/^<!-- inreplyto=\"([^\"]*)\"/) {
             $inreplyto = $1;
         }
+        elsif(/^<!-- charset=\"([^\"]*)\"/) {
+            $charset = $1;
+        }
         elsif(/^<!-- body=\"start\" -->/) {
             last;
         }
     }
     close(FILE);
+
+    if($charset =~ /utf-*8/i) {
+        # this is utf-8 while we have the output in iso8859-1 so we need
+        # a convertion
+        $subject =~ s/\"/MMMMM/g;
+        $subject = `echo "$subject" | iconv -f utf8 -t iso8859-1`;
+        $subject =~ s/MMMMM/\"/g;
+    }
+
     return $date, $name, $email, $subject, $inreplyto;
 }