[ic] Email.tag and Encode patch

Josh Lavin josh at perusion.com
Wed May 30 23:58:00 UTC 2012


When _not_ using UTF8, I found that the latest email.tag only worked for
me when Encode had already been included, because I had a filter with
"use Encode". When that filter was removed, the email.tag failed with:

Undefined subroutine &Encode::PERLQQ called at (tag 'email') line 11.

I am more than willing for others to provide insight into a better way
to fix, but this patch works for me:

https://github.com/jlavin/interchange/commit/b8eec1f7279742930acc11e8064a3eaf870b5210

--- a/code/UserTag/email.tag
+++ b/code/UserTag/email.tag
@@ -1,4 +1,4 @@
-# Copyright 2002-2010 Interchange Development Group and others
+# Copyright 2002-2012 Interchange Development Group and others
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -11,17 +11,21 @@ UserTag email addAttr
 UserTag email Interpolate
 UserTag email Routine <<EOR
 
-my $Have_mime_lite;
+my ($Have_mime_lite, $Have_encode);
 BEGIN {
        eval {
                require MIME::Lite;
                $Have_mime_lite = 1;
        };
+       eval {
+               require Encode::PERLQQ;
+               $Have_encode = 1;
+       };
 }
 
 sub utf8_to_other {
        my ($string, $encoding) = @_;
-       return $string unless defined Encode::PERLQQ(); # nop if no Encode
+       return $string unless $Have_encode; # nop if no Encode
 
        unless(Encode::is_utf8($string)){
                $string = Encode::decode('utf-8', $string);


-- 
Josh Lavin
Perusion -- Expert Interchange Consulting    http://www.perusion.com/



More information about the interchange-users mailing list