[interchange-cvs] interchange - racke modified lib/Vend/CharSet.pm
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Thu Apr 17 10:52:37 UTC 2008
User: racke
Date: 2008-04-17 10:52:37 GMT
Modified: lib/Vend CharSet.pm
Log:
remove default charset, effectively disabling UTF-8 by default until we
solved the issue with embedded Perl
log error message if decode operation fails
Revision Changes Path
2.6 interchange/lib/Vend/CharSet.pm
rev 2.6, prev_rev 2.5
Index: CharSet.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/CharSet.pm,v
retrieving revision 2.5
retrieving revision 2.6
diff -u -r2.5 -r2.6
--- CharSet.pm 26 Mar 2008 10:29:06 -0000 2.5
+++ CharSet.pm 17 Apr 2008 10:52:37 -0000 2.6
@@ -1,6 +1,6 @@
# Vend::CharSet - utility methods for handling character encoding
#
-# $Id: CharSet.pm,v 2.5 2008-03-26 10:29:06 racke Exp $
+# $Id: CharSet.pm,v 2.6 2008-04-17 10:52:37 racke Exp $
#
# Copyright (C) 2008 Interchange Development Group
#
@@ -26,17 +26,18 @@
use Encode qw( decode resolve_alias is_utf8 );
-use constant DEFAULT_ENCODING => 'utf-8';
-
sub decode_urlencode {
my ($class, $octets, $encoding) = (@_);
- $encoding ||= DEFAULT_ENCODING;
-#::logDebug("decode_urlencode--octets: $octets, encoding: $encoding");
- return undef unless $class->validate_encoding($encoding);
+#::logDebug("decode_urlencode--octets: $octets, encoding: $encoding");
$octets =~ tr/+/ /;
$octets =~ s/%([0-9a-fA-F][0-9a-fA-F])/chr(hex $1)/ge;
+
+ unless ($encoding || $class->validate_encoding($encoding)) {
+ return $octets;
+ }
+
my $string = $class->to_internal($encoding, $octets);
#::logDebug("decoded string: " . display_chars($string)) if $string;
@@ -46,14 +47,14 @@
sub to_internal {
my ($class, $encoding, $octets) = @_;
#::logDebug("to_internal - converting octets from $encoding to internal");
- if (is_utf8($octets)) {
+ if (!$encoding || is_utf8($octets)) {
#::logDebug("to_internal - octets are already utf-8 flagged");
return $octets;
}
my $string = eval { decode($encoding, $octets, Encode::FB_CROAK) };
if ($@) {
- ::logError("Unable to properly decode <%s> with encoding %s", display_chars($octets), $encoding);
+ ::logError("Unable to properly decode <%s> with encoding %s: %s", display_chars($octets), $encoding, $@);
return;
}
return $string;
More information about the interchange-cvs
mailing list