B2G/gecko/dom/mobilemessage/src/ril/MmsPduHelper.jsm
/**
   * Always encode target string with UTF-8 encoding.
   *
   * @param data
   *        A wrapped object to store encoded raw data.
   * @param str
   *        A string.
   */
Always encode target string with UTF-8 encoding.
@param data
A wrapped object to store encoded raw data.
@param str
A string.
Always encode target string with UTF - 8 encoding . @param data A wrapped object to store encoded raw data . @param str A string .
function encodeCharsetEncodedString(data, str) {
    let conv = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
               .createInstance(Ci.nsIScriptableUnicodeConverter);
    conv.charset = "UTF-8";
    let raw;
    try {
      raw = conv.convertToByteArray(str);
    } catch (e) {
      throw new WSP.CodeError("Charset-encoded-string: " + e.message);
    }
    let length = raw.length + 2; 
    if (raw[0] >= 128) {
      ++length;
    }
    WSP.ValueLength.encode(data, length);
    let entry = WSP.WSP_WELL_KNOWN_CHARSETS["utf-8"];
    WSP.IntegerValue.encode(data, entry.number);
    if (raw[0] >= 128) {
      WSP.Octet.encode(data, 127);
    }
    WSP.Octet.encodeMultiple(data, raw);
    WSP.Octet.encode(data, 0);
  }
function encodeCharsetEncodedString ( data , str ) { let conv = Cc [ "@mozilla.org/intl/scriptableunicodeconverter" ] . createInstance ( Ci . nsIScriptableUnicodeConverter ) ; conv . charset = "UTF-8" ; let raw ; try { raw = conv . convertToByteArray ( str ) ; } catch ( e ) { throw new WSP . CodeError ( "Charset-encoded-string: " + e . message ) ; } let length = raw . length + 2 ; if ( raw [ 0 ] >= 128 ) { ++ length ; } WSP . ValueLength . encode ( data , length ) ; let entry = WSP . WSP_WELL_KNOWN_CHARSETS [ "utf-8" ] ; WSP . IntegerValue . encode ( data , entry . number ) ; if ( raw [ 0 ] >= 128 ) { WSP . Octet . encode ( data , 127 ) ; } WSP . Octet . encodeMultiple ( data , raw ) ; WSP . Octet . encode ( data , 0 ) ; }
Always encode target string with UTF-8 encoding.
Always encode target string with UTF - 8 encoding .
// `When the text string cannot be represented as us-ascii, the character // set SHALL be encoded as utf-8(IANA MIBenum 106) which has unique byte // ordering.` ~ OMA-TS-MMS_CONF-V1_3-20110913-A clause 10.2.1 // Charset number and NUL character // Prepend <Octet 127> if necessary.