<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Python code to decode SMS PDU</title>
	<atom:link href="http://www.monkeysandrobots.com/archives/207/feed" rel="self" type="application/rss+xml" />
	<link>http://www.monkeysandrobots.com/archives/207</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 28 Jul 2010 07:46:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Colm O'Shea</title>
		<link>http://www.monkeysandrobots.com/archives/207/comment-page-1#comment-158</link>
		<dc:creator>Colm O'Shea</dc:creator>
		<pubDate>Fri, 18 Dec 2009 09:17:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.exothermia.net/monkeys_and_robots/?p=207#comment-158</guid>
		<description>The following table will map GSM character codes to their latin1 equivalent:
gsm_to_latin1 = [64, 163, 36, 165, 232, 233, 249, 236, 242, 199, 10, 216, 248, 13, 197, 229, 16, 95, 32, 32, 32, 32, 32, 32, 32, 32, 32, 27, 198, 230, 223, 201, 32, 33, 34, 35, 164, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 161, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 196, 214, 209, 220, 167, 191, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 228, 246, 241, 252, 224, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 94, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 123, 125, 32, 32, 32, 32, 32, 92, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 91, 126, 93, 32, 124, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]

Then change the following line of decode_user_data:
   out += chr(byte)
to:
 out += chr(gsm_to_latin1[byte])</description>
		<content:encoded><![CDATA[<p>The following table will map GSM character codes to their latin1 equivalent:<br />
gsm_to_latin1 = [64, 163, 36, 165, 232, 233, 249, 236, 242, 199, 10, 216, 248, 13, 197, 229, 16, 95, 32, 32, 32, 32, 32, 32, 32, 32, 32, 27, 198, 230, 223, 201, 32, 33, 34, 35, 164, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 161, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 196, 214, 209, 220, 167, 191, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 228, 246, 241, 252, 224, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 94, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 123, 125, 32, 32, 32, 32, 32, 92, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 91, 126, 93, 32, 124, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]</p>
<p>Then change the following line of decode_user_data:<br />
   out += chr(byte)<br />
to:<br />
 out += chr(gsm_to_latin1[byte])</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.monkeysandrobots.com/archives/207/comment-page-1#comment-157</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Tue, 01 Sep 2009 03:27:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.exothermia.net/monkeys_and_robots/?p=207#comment-157</guid>
		<description>Hi Pretty Trivial,

Can you post your code as well ?
It will save me quite some time.

Thanks a lot!

&lt;blockquote cite=&quot;#commentbody-2359&quot;&gt;
&lt;strong&gt;&lt;a href=&quot;#comment-2359&quot; rel=&quot;nofollow&quot;&gt;Pretty Trivial&lt;/a&gt; :&lt;/strong&gt;
I wrote my own one without looking at yours in the end, my decode was pretty different too! You can’t decode properly without using message length. It will work most of the time but the 7-bit GSM encoding of default alphabet uses 0×00 for the @ symbol, plus you can use your own encodings on it too if you like which may also use 0×00. Try making a string that is 8 bytes long and making the last character \x00. Every time \x00 falls on the end of a string in an octet that is a multiple of 7 then it is lost. The only way to know it is there is to use the message length.
&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<p>Hi Pretty Trivial,</p>
<p>Can you post your code as well ?<br />
It will save me quite some time.</p>
<p>Thanks a lot!</p>
<blockquote cite="#commentbody-2359"><p>
<strong><a href="#comment-2359" rel="nofollow">Pretty Trivial</a> :</strong><br />
I wrote my own one without looking at yours in the end, my decode was pretty different too! You can’t decode properly without using message length. It will work most of the time but the 7-bit GSM encoding of default alphabet uses 0×00 for the @ symbol, plus you can use your own encodings on it too if you like which may also use 0×00. Try making a string that is 8 bytes long and making the last character \x00. Every time \x00 falls on the end of a string in an octet that is a multiple of 7 then it is lost. The only way to know it is there is to use the message length.
</p></blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pretty Trivial</title>
		<link>http://www.monkeysandrobots.com/archives/207/comment-page-1#comment-156</link>
		<dc:creator>Pretty Trivial</dc:creator>
		<pubDate>Tue, 18 Aug 2009 04:28:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.exothermia.net/monkeys_and_robots/?p=207#comment-156</guid>
		<description>I wrote my own one without looking at yours in the end, my decode was pretty different too! You can&#039;t decode properly without using message length. It will work most of the time but the 7-bit GSM encoding of default alphabet uses 0x00 for the @ symbol, plus you can use your own encodings on it too if you like which may also use 0x00. Try making a string that is 8 bytes long and making the last character \x00. Every time \x00 falls on the end of a string in an octet that is a multiple of 7 then it is lost. The only way to know it is there is to use the message length.</description>
		<content:encoded><![CDATA[<p>I wrote my own one without looking at yours in the end, my decode was pretty different too! You can&#8217;t decode properly without using message length. It will work most of the time but the 7-bit GSM encoding of default alphabet uses 0&#215;00 for the @ symbol, plus you can use your own encodings on it too if you like which may also use 0&#215;00. Try making a string that is 8 bytes long and making the last character \x00. Every time \x00 falls on the end of a string in an octet that is a multiple of 7 then it is lost. The only way to know it is there is to use the message length.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pretty Trivial</title>
		<link>http://www.monkeysandrobots.com/archives/207/comment-page-1#comment-155</link>
		<dc:creator>Pretty Trivial</dc:creator>
		<pubDate>Tue, 18 Aug 2009 00:14:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.exothermia.net/monkeys_and_robots/?p=207#comment-155</guid>
		<description>Come on, that is pretty trivial. All you need is the info on the first hit from gooling &quot;sms pdu&quot; and it tells you how to do it. I was about to make this then I googled &quot;python pdu sms&quot; and you beat me to it. Thanks for saving 20 minutes!</description>
		<content:encoded><![CDATA[<p>Come on, that is pretty trivial. All you need is the info on the first hit from gooling &#8220;sms pdu&#8221; and it tells you how to do it. I was about to make this then I googled &#8220;python pdu sms&#8221; and you beat me to it. Thanks for saving 20 minutes!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carl Audet</title>
		<link>http://www.monkeysandrobots.com/archives/207/comment-page-1#comment-154</link>
		<dc:creator>Carl Audet</dc:creator>
		<pubDate>Thu, 11 Jun 2009 21:35:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.exothermia.net/monkeys_and_robots/?p=207#comment-154</guid>
		<description>Thank you very much, this was really helpful, especially given how rusty was my python-fu (now I remmber why I like it so much). You should verify your def decode_user_data function though, it leaves the last characters out for strings that have a multiple of 8 as a length.
I&#039;ve added that line before the return statement:

if strip == 7:  out += chr(ls)

(ok, not that elegant, but that fixes it)

You probably are also aware that the module as it is doesn&#039;t handle characters that don&#039;t have a 1:1 mapping from unicode / GSM encoding ( fixed it with a simple dict lookup).

Whoever designed that PDU user data protocol deserves to be repeatedly slapped in the face...

Thanks again for sharing.

Cheers.</description>
		<content:encoded><![CDATA[<p>Thank you very much, this was really helpful, especially given how rusty was my python-fu (now I remmber why I like it so much). You should verify your def decode_user_data function though, it leaves the last characters out for strings that have a multiple of 8 as a length.<br />
I&#8217;ve added that line before the return statement:</p>
<p>if strip == 7:  out += chr(ls)</p>
<p>(ok, not that elegant, but that fixes it)</p>
<p>You probably are also aware that the module as it is doesn&#8217;t handle characters that don&#8217;t have a 1:1 mapping from unicode / GSM encoding ( fixed it with a simple dict lookup).</p>
<p>Whoever designed that PDU user data protocol deserves to be repeatedly slapped in the face&#8230;</p>
<p>Thanks again for sharing.</p>
<p>Cheers.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
