From c9ca8baf7955cdb7533d5c4e54a6f4ce324c4636 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Thu, 9 Mar 2017 16:25:10 +0100 Subject: [PATCH] TT#12660 Also send latin1 as gsm encoding. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Except for greek characters, which are available in the GSM 03.38 encoding but not in latin-1, all other latin-1 characters can be sent with coding 0 (7bit). We neither support the € sign available in the GSM extended encoding, but for unknown reasons the rest of the extended char sets (which are part of ascii anways) do work. So, no € and no greek chars inside coding=0. Change-Id: Ia87e337772e126b6a0a95b53acba0a369b71e660 --- lib/NGCP/Panel/Controller/API/SMS.pm | 8 +------- lib/NGCP/Panel/Utils/SMS.pm | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/lib/NGCP/Panel/Controller/API/SMS.pm b/lib/NGCP/Panel/Controller/API/SMS.pm index cedf5b88ea..204a7efe01 100644 --- a/lib/NGCP/Panel/Controller/API/SMS.pm +++ b/lib/NGCP/Panel/Controller/API/SMS.pm @@ -133,13 +133,7 @@ sub create_item { } my $error_msg = ""; - - my $coding; - if(NGCP::Panel::Utils::Utf8::is_within_ascii($resource->{text})) { - $coding = 0; - } else { - $coding = 2; - } + my $coding = NGCP::Panel::Utils::SMS::get_coding($resource->{text}); NGCP::Panel::Utils::SMS::send_sms( c => $c, caller => $resource->{caller}, diff --git a/lib/NGCP/Panel/Utils/SMS.pm b/lib/NGCP/Panel/Utils/SMS.pm index 4fa3668822..ed6a454fec 100644 --- a/lib/NGCP/Panel/Utils/SMS.pm +++ b/lib/NGCP/Panel/Utils/SMS.pm @@ -9,6 +9,24 @@ use Module::Load::Conditional qw/can_load/; use NGCP::Panel::Utils::Utf8; +sub get_coding { + my $text = shift; + + # if unicode, we have to use utf8 encoding, limiting our + # text length to 70; otherwise send as default + # encoding, allowing 160 chars + + my $coding; + if(NGCP::Panel::Utils::Utf8::is_within_ascii($text) || + NGCP::Panel::Utils::Utf8::is_within_latin1($text)) { + $coding = 0; + } else { + $coding = 2; + } + + return $coding; +} + sub send_sms { my (%args) = @_; my $c = $args{c}; @@ -23,14 +41,7 @@ sub send_sms { } unless(defined $coding) { - # if unicode, we have to use utf8 encoding, limiting our - # text length to 70; otherwise send as default - # encoding, allowing 160 chars - if(NGCP::Panel::Utils::Utf8::is_within_ascii($text)) { - $coding = 0; - } else { - $coding = 2; - } + $coding = get_coding($text); } my $schema = $c->config->{sms}{schema};