From 1b86b3de5e813702674afb8ac32d05516cb5c396 Mon Sep 17 00:00:00 2001 From: gmc <gmc@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Thu, 4 Nov 2010 01:03:42 +0000 Subject: [PATCH] add TT helper to squeeze strings into the UNOB straitjacket The force_jedi_unob helper strips non-ASCII characters from template output but does so nicely by converting the string to NFD first. This is meant to be used by EDI templates, although could be useful for A/T output that goes to receipt printers that cannot print diacritics. Signed-off-by: Galen Charlton <gmc@esilibrary.com> git-svn-id: svn://svn.open-ils.org/ILS/trunk@18598 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm index cc59bbd177..4be542b0d6 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm @@ -3,6 +3,7 @@ use strict; use warnings; use Template; use DateTime; use DateTime::Format::ISO8601; +use Unicode::Normalize; use OpenSRF::Utils qw/:datetime/; use OpenSRF::Utils::Logger qw(:logger); use OpenILS::Application::AppUtils; @@ -48,6 +49,15 @@ my $_TT_helpers = { return $str; }, + # strip non-ASCII characters after splitting base characters and diacritics + # least common denominator for EDIFACT messages using the UNOB character set + force_jedi_unob => sub { + my $str = shift; + $str = NFD($str); + $str =~ s/[\x{0080}-\x{fffd}]//g; + return $str; + }, + # returns the calculated user locale get_user_locale => sub { my $user_id = shift; -- 2.11.0