js/sms_message_analyser.js
/** 
 * Encode message according to the "UCS2" (Unicode) alphabet.
 * The function is being initialized with the "message" input by the user.
 * The function returns:
 * - the message in its "encoded" (hex) "PDU" representation,
 * - the charset used,
 * - the number of "encoded" message characters,
 * - the number of "hex" characters that represent the "encoded" message text.
 */
Encode message according to the "UCS2" (Unicode) alphabet.
The function is being initialized with the "message" input by the user.
Encode message according to the " UCS2 " ( Unicode ) alphabet . The function is being initialized with the " message " input by the user .
function encode_UCS2(msg) {
  if (msg === null) {
    return null;
  }
  var pdu = [];
  var c = 0;
  for (i = 0; i < msg.length; i++) {    
    c = msg.charCodeAt(i);
    pdu.push((ToHex((c & 0xff00) >> 8)) + (ToHex(c & 0xff)));
  }
  return {
    pdu: pdu.join(''),
    pdu_characters: pdu.length,
    pdu_hex_characters: pdu.length * 4,
    pdu_encoding: "UCS2"
  };
}
function encode_UCS2 ( msg ) { if ( msg === null ) { return null ; } var pdu = [ ] ; var c = 0 ; for ( i = 0 ; i < msg . length ; i ++ ) { c = msg . charCodeAt ( i ) ; pdu . push ( ( ToHex ( ( c & 0xff00 ) >> 8 ) ) + ( ToHex ( c & 0xff ) ) ) ; } return { pdu : pdu . join ( '' ) , pdu_characters : pdu . length , pdu_hex_characters : pdu . length * 4 , pdu_encoding : "UCS2" } ; }
Encode message according to the "UCS2" (Unicode) alphabet.
Encode message according to the " UCS2 " ( Unicode ) alphabet .
/** Input message null; exit immediately. */ /** Initialize "PDU" array. Each array position will hold a character, in "hex" format, encoded according to the "UCS2" (Unicode) alphabet. */ /** Initialize variable that will hold the (decimal) "code" of a message char. */ /** 
   * Loop through all message characters, getting the (decimal) "code" of the char at the current index in this string. 
   * Then "convert" this decimal "code" to its "16bit-hex" form, finally pushing "hex" value into the "PDU" array. 
   */ /** Return an "object" consisting of: */ /** the message in its "encoded" (hex) "PDU" representation. */ /** the number of "encoded" message characters. */ /** 
	 * the number of "hex" characters that represent the "encoded" message text; one "encoded" char is 
	 * represented by two "hex" numbers (four "hex" chars). 
	 */ /** the charset used; "UCS2" by default of course. */