[open-ils-commits] r10573 - trunk/Open-ILS/src/perlmods/OpenILS/Application

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Sep 10 21:50:16 EDT 2008


Author: erickson
Date: 2008-09-10 21:50:14 -0400 (Wed, 10 Sep 2008)
New Revision: 10573

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Log:
added a common entityize function to prevent the contining spread

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm	2008-09-11 01:48:50 UTC (rev 10572)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm	2008-09-11 01:50:14 UTC (rev 10573)
@@ -11,6 +11,7 @@
 use Data::Dumper;
 use OpenILS::Utils::CStoreEditor;
 use OpenILS::Const qw/:const/;
+use Unicode::Normalize;
 
 # ---------------------------------------------------------------------------
 # Pile of utilty methods used accross applications.
@@ -1474,5 +1475,22 @@
 	return 'en-US';
 }
 
+
+# xml-escape non-ascii characters
+sub entityize { 
+    my($self, $string, $form) = @_;
+	$form ||= "";
+
+	if ($form eq 'D') {
+		$string = NFD($string);
+	} else {
+		$string = NFC($string);
+	}
+
+	$string =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
+	return $string;
+}
+
+
 1;
 



More information about the open-ils-commits mailing list