[interchange-cvs] [SCM] Interchange branch, master, updated. REL_5_7_3-25-g10929c6

David Christensen interchange-cvs at icdevgroup.org
Tue Nov 24 22:21:17 UTC 2009


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Interchange".

The branch, master has been updated
       via  10929c6cb0ba3eb7a5ac9da927692b9280651cd2 (commit)
      from  a53a95540d2d8892a7c5ad4d6960adc95ccfe014 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 10929c6cb0ba3eb7a5ac9da927692b9280651cd2
Author: David Christensen <david at endpoint.com>
Date:   Tue Nov 24 16:20:22 2009 -0600

    Add Vend::CharSet::mime_name for installations which lack proper Encode.pm support
    
    Not all versions of Encode in IC-supported perl versions support the
    mime_name method.  This patch adds checking for the existance of the
    method, and provides a simple replacement in the case that it lacks
    it.
    
    The main goal here is to support earlier versions of Encode.pm, while
    still allowing us to normalize and use the utf8 charset.
    
    Additional special-cases can be added to Vend::CharSet::mime_name as needed.

-----------------------------------------------------------------------

Summary of changes and diff:
 lib/Vend/CharSet.pm |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/lib/Vend/CharSet.pm b/lib/Vend/CharSet.pm
index 37d0dae..578f136 100644
--- a/lib/Vend/CharSet.pm
+++ b/lib/Vend/CharSet.pm
@@ -73,11 +73,26 @@ sub to_internal {
 	return $octets;
 }
 
+# returns a true value (the normalized name of the encoding) if the
+# specified encoding is recognized by Encode.pm, otherwise return
+# nothing.
 sub validate_encoding {
 	my $encoding = shift;
 	my $enc = find_encoding($encoding);
 
-	return $enc && $enc->mime_name;
+    return unless $enc;
+	return $enc->can('mime_name') ? $enc->mime_name : mime_name($enc->name);
+}
+
+# fallback routine to provide a pretty-style mime_name in versions of
+# Encode which predate the actual method.  The main use would be to
+# normalize "utf8-strict" to "utf8", but there are other cases where
+# this can/will come in handy.
+sub mime_name {
+    my $encoding_name = shift;
+
+    $encoding_name =~ s/-strict//i;
+    return lc $encoding_name;
 }
 
 sub default_charset {


hooks/post-receive
-- 
Interchange



More information about the interchange-cvs mailing list