--- smsdaemon/SmsPdu.cpp 2008/06/13 07:56:57 70 +++ smsdaemon/SmsPdu.cpp 2008/12/07 00:59:05 132 @@ -13,11 +13,9 @@ #include "common.h" #include "util.h" -#include using namespace std; - namespace SmsPdu { @@ -36,6 +34,9 @@ string EncodePhonenr(string input) { + if ( input.at(0) == '+' ) + input.erase(0,1); + if ( (input.length() % 2) == 1) input.append("F"); return SwitchChars(input); @@ -78,7 +79,7 @@ return vec; } - std::string Decode8to7bit(vector input, int shift_start = 0) + std::string Decode8to7bit(vector input, int shift_start) { string result; @@ -110,11 +111,11 @@ - vector Encode7to8bit(std::string str) + vector Encode7to8bit(std::string str, int shift_start) { vector buf; - int shift = 0; + int shift = shift_start; for (unsigned int i=0; i phone = HexDecodeString( EncodePhonenr(to )); pdu.insert( pdu.end(), phone.begin(), phone.end()); pdu.push_back(0x00); // Protocol identifier pdu.push_back(0x00); // Data coding scheme + int shift_start = 0; string message_part; if (multipart) { @@ -199,7 +200,7 @@ pdu.push_back( part_count ); pdu.push_back( partnr+1 ); pdu.push_back( 0x00); - + //shift_start = 6; } else { @@ -216,7 +217,7 @@ pdu.push_back( message_part.length() ); //UserDataLength } - vector userData = Encode7to8bit(message_part); + vector userData = Encode7to8bit(message_part, shift_start); pdu.insert( pdu.end(), userData.begin(), userData.end()); @@ -309,19 +310,19 @@ if (UDHI) { int udh_len = (*it++); - cout << "UDH_LEN:" << udh_len << endl; it += udh_len; //just ignore the User Data Header data_len -= udh_len; shift_start = udh_len+1; //make the 8to7bit decode start with the right shift level } - cout << hex<< (int)(*it) << endl;; vector user_data; user_data.insert(user_data.end(), it, it+data_len); - result.message = Decode8to7bit(user_data, shift_start); + result.message = Decode8to7bit(user_data, shift_start).substr(0,data_len); + + result.message = Util::str_trim(result.message); return result;