Subject: | bug report for Device/Gsm/Pdu.pm, Version 1.54 |
Date: | Tue, 18 May 2010 16:21:16 +0200 |
To: | "bug-Device-Gsm [...] rt.cpan.org" <bug-Device-Gsm [...] rt.cpan.org> |
From: | "Koessldorfer,Erich" <Erich.Koessldorfer [...] drei.com> |
Hi COSIMO!
I'd like to report a bug in the module Pdu.pm. The bug is related to bug 20906, "Problem with Russian letters in SMS". The correction made there is not correct. When reading messages with $gsm->messages() characters above 0x80 are not displayed correctly, they are not converted to UTF-8. The reason is a wrong format at the pack statement.
Line 167 now looks like:
$decoded.=pack("U",hex(substr($encoded,0,4)));
but should look like:
$decoded.=pack("C0U",hex(substr($encoded,0,4)));
I tested with the string Øñóº which are all characters between 0x80 and 0xff. Version 1.54 returns the message text as Windows-1252 encoded. With the format "C0U" the correct UTF-8 encoded text is returned.
The code looks like:
my $gsm = new Device::Gsm(...);
my @msg = $gsm->messages();
foreach( @msg ) {
printf("%s\n", $_->text());
}
When piped through "od -c" command, the output looks like:
330 361 363 272
which is wrong, correct output is:
303 230 303 261 303 263 302 272
Kind regards,
Erich Kößldorfer