From 01060bb8d483dfb56fa8d386d3bd203db288b610 Mon Sep 17 00:00:00 2001 From: Johanna Raisa Date: Thu, 2 Sep 2021 13:38:44 +0300 Subject: [PATCH] Add hdiacritic to driver --- .../lib/SMS/Send/LinkMobility/Driver.pm | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Koha/Plugin/Fi/KohaSuomi/SMSSendLinkMobilityDriver/lib/SMS/Send/LinkMobility/Driver.pm b/Koha/Plugin/Fi/KohaSuomi/SMSSendLinkMobilityDriver/lib/SMS/Send/LinkMobility/Driver.pm index d3500db..97eb192 100644 --- a/Koha/Plugin/Fi/KohaSuomi/SMSSendLinkMobilityDriver/lib/SMS/Send/LinkMobility/Driver.pm +++ b/Koha/Plugin/Fi/KohaSuomi/SMSSendLinkMobilityDriver/lib/SMS/Send/LinkMobility/Driver.pm @@ -2,10 +2,11 @@ package SMS::Send::LinkMobility::Driver; #use Modern::Perl; #Can't use this since SMS::Send uses hash keys starting with _ use SMS::Send::Driver (); use LWP::Curl; -use LWP::UserAgent; use URI::Escape; use C4::Context; use Encode; +use Unicode::Normalize; +use Koha::Notice::Messages; use Try::Tiny; @@ -59,6 +60,31 @@ sub new { return $self; } +sub hdiacritic { + my $char; + my $oldchar; + my $retstring; + + foreach (split(//, $_[0])) { + $char=$_; + $oldchar=$char; + + unless ( $char =~/[A-Za-z0-9ÅåÄäÖöÉéÈèÌìÍíÓóÒòÔôÎîÇçÆæÏïÜüÐðØøÞþßÕõÑñÛûÂâÊêËëÃãÝýÀàÁáÂâÚúÙùÿ]/ ) { + + $char='Z' if $char eq 'Ʒ'; + $char='z' if $char eq 'ʒ'; + $char='Ð' if $char eq 'Ɖ'; + $char='Ð' if $char eq 'Đ'; # This is not the same as above, so don't remove either one! + $char='\'' if $char eq 'ʻ'; + + $char=NFKD($char) if "$oldchar" eq "$char"; + } + $retstring=$retstring . $char; + } + + return $retstring; +} + sub send_sms { my $self = shift; my $params = {@_};