[otrs-cvs] otrs/Kernel/System YAML.pm,1.2,1.3

"CVS commits notifications of OTRS.org" <[email protected]>
Newsgroups gmane.comp.otrs.cvs
Message-ID <[email protected]>
Comments:
Update of /home/cvs/otrs/Kernel/System
In directory lancelot:/tmp/cvs-serv11973/Kernel/System

Modified Files:
	YAML.pm 
Log Message:
Improved Kernel::System::YAML to handle unicode well with all backends.
Added tests for both YAML::XS and YAML, respectively.

Author: mg

Index: YAML.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/System/YAML.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -2 -u -d -r1.2 -r1.3
--- YAML.pm	16 Jan 2013 07:41:26 -0000	1.2
+++ YAML.pm	16 Jan 2013 09:02:28 -0000	1.3
@@ -50,7 +50,57 @@
     };
 
+    _AddUTF8Flag( \$Result ) if defined $Result;
+
     return $Result;
 }
 
+=item _AddUTF8Flag()
+
+adds the UTF8 flag to all elements in a complex data structure.
+
+=cut
+
+sub _AddUTF8Flag {
+    my ($Data) = @_;
+
+    if ( !ref ${$Data} ) {
+        Encode::_utf8_on( ${$Data} );
+        return;
+    }
+
+    if ( ref ${$Data} eq 'SCALAR' ) {
+        return _AddUTF8Flag( ${$Data} );
+    }
+
+    if ( ref ${$Data} eq 'HASH' ) {
+        KEY:
+        for my $Key ( sort keys %{ ${$Data} } ) {
+            next KEY if !defined ${$Data}->{$Key};
+            _AddUTF8Flag( \${$Data}->{$Key} );
+        }
+        return;
+    }
+
+    if ( ref ${$Data} eq 'ARRAY' ) {
+        KEY:
+        for my $Key ( 0 .. $#{ ${$Data} } ) {
+            next KEY if !defined ${$Data}->[$Key];
+            _AddUTF8Flag( \${$Data}->[$Key] );
+        }
+        return;
+    }
+
+    if ( ref ${$Data} eq 'REF' ) {
+        return _AddUTF8Flag( ${$Data} );
+    }
+
+    #$Self->{LogObject}->Log(
+    #    Priority => 'error',
+    #    Message  => "Unknown ref '" . ref( ${$Data} ) . "'!",
+    #);
+
+    return;
+}
+
 1;
 
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.