B2G/gecko/dom/system/gonk/RadioInterfaceLayer.js
/**
   * Calculate user data length of specified message string encoded in UCS2.
   *
   * @param message
   *        a message string to be encoded.
   *
   * @return an options object with attributes `dcs`, `userDataHeaderLength`,
   *         `encodedFullBodyLength`, `segmentMaxSeq` set.
   *
   * @see #_calculateUserDataLength().
   */
Calculate user data length of specified message string encoded in UCS2.
@param message
a message string to be encoded.




Calculate user data length of specified message string encoded in UCS2 . @param message a message string to be encoded .
function _calculateUserDataLengthUCS2(message) {
    let bodyChars = message.length;
    let headerLen = 0;
    let headerChars = Math.ceil((headerLen ? headerLen + 1 : 0) / 2);
    let segmentChars = RIL.PDU_MAX_USER_DATA_UCS2;
    if ((bodyChars + headerChars) > segmentChars) {
      headerLen += this.segmentRef16Bit ? 6 : 5;
      headerChars = Math.ceil((headerLen + 1) / 2);
      segmentChars -= headerChars;
    }
    let segments = Math.ceil(bodyChars / segmentChars);
    return {
      dcs: RIL.PDU_DCS_MSG_CODING_16BITS_ALPHABET,
      encodedFullBodyLength: bodyChars * 2,
      userDataHeaderLength: headerLen,
      segmentMaxSeq: segments,
      segmentChars: segmentChars,
    };
  }
function _calculateUserDataLengthUCS2 ( message ) { let bodyChars = message . length ; let headerLen = 0 ; let headerChars = Math . ceil ( ( headerLen ? headerLen + 1 : 0 ) / 2 ) ; let segmentChars = RIL . PDU_MAX_USER_DATA_UCS2 ; if ( ( bodyChars + headerChars ) > segmentChars ) { headerLen += this . segmentRef16Bit ? 6 : 5 ; headerChars = Math . ceil ( ( headerLen + 1 ) / 2 ) ; segmentChars -= headerChars ; } let segments = Math . ceil ( bodyChars / segmentChars ) ; return { dcs : RIL . PDU_DCS_MSG_CODING_16BITS_ALPHABET , encodedFullBodyLength : bodyChars * 2 , userDataHeaderLength : headerLen , segmentMaxSeq : segments , segmentChars : segmentChars , } ; }
Calculate user data length of specified message string encoded in UCS2.
Calculate user data length of specified message string encoded in UCS2 .