B2G/gecko/dom/system/gonk/RadioInterfaceLayer.js
/**
   * Fragment GSM 7-Bit encodable string for transmission.
   *
   * @param text
   *        text string to be fragmented.
   * @param langTable
   *        locking shift table string.
   * @param langShiftTable
   *        single shift table string.
   * @param segmentSeptets
   *        Number of available spetets per segment.
   * @param strict7BitEncoding
   *        Optional. Enable Latin characters replacement with corresponding
   *        ones in GSM SMS 7-bit default alphabet.
   *
   * @return an array of objects. See #_fragmentText() for detailed definition.
   */
Fragment GSM 7-Bit encodable string for transmission.
@param text
text string to be fragmented.
@param langTable
locking shift table string.
@param langShiftTable
single shift table string.
@param segmentSeptets
Number of available spetets per segment.

@return an array of objects. See #_fragmentText() for detailed definition.
Fragment GSM 7 - Bit encodable string for transmission . @param text text string to be fragmented . @param langTable locking shift table string . @param langShiftTable single shift table string . @param segmentSeptets Number of available spetets per segment . @return an array of objects . See #_fragmentText () for detailed definition .
function _fragmentText7Bit(text, langTable, langShiftTable, segmentSeptets, strict7BitEncoding) {
    let ret = [];
    let body = "", len = 0;
    for (let i = 0, inc = 0; i < text.length; i++) {
      let c = text.charAt(i);
      if (strict7BitEncoding) {
        c = RIL.GSM_SMS_STRICT_7BIT_CHARMAP[c] || c;
      }
      let septet = langTable.indexOf(c);
      if (septet == RIL.PDU_NL_EXTENDED_ESCAPE) {
        continue;
      }
      if (septet >= 0) {
        inc = 1;
      } else {
        septet = langShiftTable.indexOf(c);
        if (septet == RIL.PDU_NL_RESERVED_CONTROL) {
          continue;
        }
        inc = 2;
        if (septet < 0) {
          if (!strict7BitEncoding) {
            throw new Error("Given text cannot be encoded with GSM 7-bit Alphabet!");
          }
          c = '*';
          if (langTable.indexOf(c) >= 0) {
            inc = 1;
          }
        }
      }
      if ((len + inc) > segmentSeptets) {
        ret.push({
          body: body,
          encodedBodyLength: len,
        });
        body = c;
        len = inc;
      } else {
        body += c;
        len += inc;
      }
    }
    if (len) {
      ret.push({
        body: body,
        encodedBodyLength: len,
      });
    }
    return ret;
  }
function _fragmentText7Bit ( text , langTable , langShiftTable , segmentSeptets , strict7BitEncoding ) { let ret = [ ] ; let body = "" , len = 0 ; for ( let i = 0 , inc = 0 ; i < text . length ; i ++ ) { let c = text . charAt ( i ) ; if ( strict7BitEncoding ) { c = RIL . GSM_SMS_STRICT_7BIT_CHARMAP [ c ] || c ; } let septet = langTable . indexOf ( c ) ; if ( septet == RIL . PDU_NL_EXTENDED_ESCAPE ) { continue ; } if ( septet >= 0 ) { inc = 1 ; } else { septet = langShiftTable . indexOf ( c ) ; if ( septet == RIL . PDU_NL_RESERVED_CONTROL ) { continue ; } inc = 2 ; if ( septet < 0 ) { if ( ! strict7BitEncoding ) { throw new Error ( "Given text cannot be encoded with GSM 7-bit Alphabet!" ) ; } c = '*' ; if ( langTable . indexOf ( c ) >= 0 ) { inc = 1 ; } } } if ( ( len + inc ) > segmentSeptets ) { ret . push ( { body : body , encodedBodyLength : len , } ) ; body = c ; len = inc ; } else { body += c ; len += inc ; } } if ( len ) { ret . push ( { body : body , encodedBodyLength : len , } ) ; } return ret ; }
Fragment GSM 7-Bit encodable string for transmission.
Fragment GSM 7 - Bit encodable string for transmission .
// Bug 816082, when strict7BitEncoding is enabled, we should replace // characters that can't be encoded with GSM 7-Bit alphabets with '*'.