commit 5ce6a9e9173dce95287ff4b15deda67b569dd365 Author: Heinrich Langos Date: Mon Apr 14 19:49:54 2008 +0200 Changed encoding of unicode characters outside of ascii range to XML notation. This change will make your GNUtunesDB.xml into a pure ascii file. Making it easier to view and manipulate on non-utf8 capable systems. Note: "xescaped()" is not only called for attribute values but also for element names and attribute names. So if sombody comes up with non-ascii element names or attribute names we would have to treat those differently. diff --git a/src/ext/XMLhelper.pm b/src/ext/XMLhelper.pm index 5eaeb48..2a230a3 100755 --- a/src/ext/XMLhelper.pm +++ b/src/ext/XMLhelper.pm @@ -124,8 +124,15 @@ sub xescaped { my $xutf = Unicode::String::utf8($ret)->utf8; #Remove 0x00 - 0x1f chars (we don't need them) $xutf =~ tr/\000-\037//d; - - return $xutf; + my $out = Unicode::String::utf8("")->utf8; + for (my $i = 0 ; $i < Unicode::String::utf8($xutf)->length ; $i++) { + if (Unicode::String::utf8($xutf)->substr($i,1)->ord > 127) { + $out .= '&#' . Unicode::String::utf8($xutf)->substr($i,1)->ord . ';'; + } else { + $out .= Unicode::String::utf8($xutf)->substr($i,1) ; + } + } + return $out; }