Lines 9-14
use warnings;
Link Here
|
9 |
use English; |
9 |
use English; |
10 |
use Exporter; |
10 |
use Exporter; |
11 |
|
11 |
|
|
|
12 |
use Encode; |
13 |
use Unicode::Normalize; |
14 |
|
12 |
use Sys::Syslog qw(syslog); |
15 |
use Sys::Syslog qw(syslog); |
13 |
use POSIX qw(strftime); |
16 |
use POSIX qw(strftime); |
14 |
use Socket qw(:crlf); |
17 |
use Socket qw(:crlf); |
Lines 142-147
sub boolspace {
Link Here
|
142 |
return $bool ? 'Y' : ' '; |
145 |
return $bool ? 'Y' : ' '; |
143 |
} |
146 |
} |
144 |
|
147 |
|
|
|
148 |
sub clean_text { |
149 |
my $text = shift || ''; |
150 |
|
151 |
# hardcoded to ASCII since Koha configs don't take encoding as institution params |
152 |
my $target_encoding = 'ascii'; |
153 |
|
154 |
# Convert our incoming UTF8 data into Perl's internal string format |
155 |
|
156 |
# Also convert to Normalization Form D, as the ASCII, iso-8859-1, |
157 |
# and latin-1 encodings (at least) require this to substitute |
158 |
# characters rather than simply returning a string truncated |
159 |
# after the first non-ASCII character |
160 |
$text = NFD(decode_utf8($text)); |
161 |
|
162 |
if ($target_encoding eq 'ascii') { |
163 |
|
164 |
# Try to maintain a reasonable version of the content by |
165 |
# stripping diacritics from the text, given that the SIP client |
166 |
# wants just plain ASCII. This is the base requirement according |
167 |
# to the SIP2 specification. |
168 |
|
169 |
$text =~ s/\pM+//og; |
170 |
} |
171 |
|
172 |
# Characters that cannot be represented in the target encoding will |
173 |
# generally be replaced with a question mark (?) character. |
174 |
$text = encode($target_encoding, $text); |
175 |
|
176 |
return $text; |
177 |
} |
178 |
|
145 |
|
179 |
|
146 |
# read_SIP_packet($file) |
180 |
# read_SIP_packet($file) |
147 |
# |
181 |
# |
Lines 218-224
sub write_msg {
Link Here
|
218 |
my ($self, $msg, $file) = @_; |
252 |
my ($self, $msg, $file) = @_; |
219 |
my $cksum; |
253 |
my $cksum; |
220 |
|
254 |
|
221 |
# $msg = encode_utf8($msg); |
255 |
$msg = clean_text($msg); |
222 |
if ($error_detection) { |
256 |
if ($error_detection) { |
223 |
if (defined($self->{seqno})) { |
257 |
if (defined($self->{seqno})) { |
224 |
$msg .= 'AY' . $self->{seqno}; |
258 |
$msg .= 'AY' . $self->{seqno}; |
225 |
- |
|
|