MCPcopy Create free account
hub / github.com/RangeNetworks/openbts / encode7bit

Method encode7bit

SMS/SMSMessages.cpp:492–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490}
491
492void TLUserData::encode7bit(const char *text)
493{
494 size_t wp = 0;
495
496 // 1. Prepare.
497 // Default alphabet (7-bit)
498 mDCS = 0;
499 // With 7-bit encoding TP-User-Data-Length count septets, i.e. just number
500 // of characters.
501 mLength = strlen(text);
502 int bytes = (mLength*7+7)/8;
503 int filler_bits = bytes*8-mLength*7;
504 mRawData.resize(bytes*8);
505
506 // 2. Write TP-UD
507 // This tail() works because UD is always the last field in the PDU.
508 BitVector2 chars = mRawData.tail(wp);
509 for (unsigned i=0; i<mLength; i++) {
510 char gsm = encodeGSMChar(text[i]);
511 mRawData.writeFieldReversed(wp,gsm,7);
512 }
513 mRawData.writeField(wp,0,filler_bits);
514}
515
516std::string TLUserData::decode() const
517{

Callers

nothing calls this directly

Calls 2

tailMethod · 0.80
writeFieldMethod · 0.45

Tested by

no test coverage detected