TT#10830 Fix calculating multi-part sms chunking

In GSM encoding for ascii-only messages, we can have 160 chars in
a single message, or 153 chars each for multi-part messages.
In UTF8, it's 70 and 67, respectively.

Change-Id: I50d95f9d0335b42457238234a4fd552401c8fb26
changes/22/11522/4
Andreas Granig 8 years ago
parent 9663c1cf69
commit cfd3a12e7d

@ -155,11 +155,15 @@ sub _glob_matches {
sub get_number_of_parts {
my $text = shift;
my $maxlen;
my $maxlen;
if(NGCP::Panel::Utils::Utf8::is_within_ascii($text)) {
$maxlen = 160;
# multi-part sms consist of 153 char chunks in ascii,
# otherwise 160 for single sms
$maxlen = length($text) <= 160 ? 160 : 153;
} else {
$maxlen = 70;
# multi-part sms consist of 67 char chunks in utf8,
# otherwise 70 for single sms
$maxlen = length($text) <= 70 ? 70 : 67;
}
return ceil(length($text) / $maxlen);
}

Loading…
Cancel
Save