a TT2 wrapper to Unicode::Normalize
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 19 Nov 2005 04:19:24 +0000 (04:19 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 19 Nov 2005 04:19:24 +0000 (04:19 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2089 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Template/Plugin/Unicode.pm [new file with mode: 0644]

diff --git a/Open-ILS/src/perlmods/OpenILS/Template/Plugin/Unicode.pm b/Open-ILS/src/perlmods/OpenILS/Template/Plugin/Unicode.pm
new file mode 100644 (file)
index 0000000..6a34237
--- /dev/null
@@ -0,0 +1,12 @@
+package OpenILS::Template::Plugin::Unicode;
+use Unicode::Normalize;
+
+sub new { return bless {}, __PACKAGE__ }
+sub load { return __PACKAGE__ }
+
+sub C { shift; return NFC(@_); }
+sub D { shift; return NFD(@_); }
+sub entityDecode { shift; $_ = shift; s/&#x([0-9a-fA-F]+);/chr(hex($1))/egos; return $_ }
+sub entityEncode { shift; $_ = shift; s/(\PM\pM+)/sprintf('&#x%0.4x;',ord(NFC($1)))/sgoe; return $_ }
+
+1;