Subject: | Problem with Russian letters in SMS |
Device-Gsm does not work well with Russian (and other non 7-bit)
letters in SMS. Here is a patch that solves this problem.
Subject: | Pdu.pm.diff |
--- Pdu.pm.etalon 2006-08-03 18:36:18.000000000 +0400
+++ Pdu.pm 2006-08-09 14:00:15.214871448 +0400
@@ -81,6 +81,20 @@
$decoded;
}
+sub decode_test_UCS2 {
+ my $encoded= shift;
+ return undef unless $encoded;
+
+ my $len = hex substr( $encoded, 0, 2 );
+ $encoded = substr $encoded, 2;
+
+ my $decoded="";
+ while( $encoded ) {
+ $decoded.=pack("U",hex(substr($encoded,0,4)));
+ $encoded = substr($encoded,4);
+ }
+ return $decoded;
+}
sub encode_address {
my $num = shift();
Subject: | UD.pm.diff |
--- UD.pm.etalon 2006-08-03 15:57:40.000000000 +0400
+++ UD.pm 2006-08-09 13:58:48.016127672 +0400
@@ -31,11 +31,17 @@
my $ud_len = hex substr($$rMessage, 0, 2);
# Finally get text of message
- # XXX Here assume that DCS == 0x00 (7 bit coding)
- my $text = Device::Gsm::Pdu::decode_text7($$rMessage);
-
- # Convert text from GSM 03.38 to Latin 1
- $text = Device::Gsm::Charset::gsm0338_to_iso8859($text);
+ my $dcs= $self->get('_messageTokens')->{'DCS'}->get('_data')->[0];
+ my $text;
+ if ($dcs == 8) {
+ $text = Device::Gsm::Pdu::decode_test_UCS2($$rMessage);
+ } else {
+ # XXX Here assume that DCS == 0x00 (7 bit coding)
+ $text = Device::Gsm::Pdu::decode_text7($$rMessage);
+
+ # Convert text from GSM 03.38 to Latin 1
+ $text = Device::Gsm::Charset::gsm0338_to_iso8859($text);
+ }
$self->set( 'length' => $ud_len );
$self->set( 'text' => $text );