Decodes PDU user data (UDHI (if present) and message text)
190208
def _decodeUserData(byteIter, userDataLen, dataCoding, udhPresent):
    
    result = {}
    if udhPresent:
        # User Data Header is present
        result['udh'] = []
        udhLen = next(byteIter)
        ieLenRead = 0
        # Parse and store UDH fields
        while ieLenRead < udhLen:
            ie = InformationElement.decode(byteIter)
            ieLenRead += len(ie)
            result['udh'].append(ie)
        del ieLenRead
        if dataCoding == 0x00: # GSM-7
            # Since we are using 7-bit data, "fill bits" may have been added to make the UDH end on a septet boundary
            shift = ((udhLen + 1) * 8) % 7 # "fill bits" needed to make the UDH end on a septet boundary
            # Simulate another "shift" in the unpackSeptets algorithm in order to ignore the fill bits
            prevOctet = next(byteIter)
            shift += 1

    if dataCoding == 0x00: # GSM-7
        if udhPresent:
            userDataSeptets = unpackSeptets(byteIter, userDataLen, prevOctet, shift)
        else:
            userDataSeptets = unpackSeptets(byteIter, userDataLen)
        result['text'] = decodeGsm7(userDataSeptets)
    elif dataCoding == 0x02: # UCS2
        result['text'] = decodeUcs2(byteIter, userDataLen)
    else: # 8-bit (data)
        userData = []
        for b in byteIter:
            userData.append(unichr(b))
        result['text'] = ''.join(userData)
    return result
770183
def decode_pc23_message(raw_string):
    

    data = {}
    wcy = raw_string.split("^")
    data[const.R] = int(wcy[1])
    data[const.expk] = int(wcy[2])
    data[const.CALLSIGN] = wcy[3]
    data[const.A] = wcy[4]
    data[const.SFI] = wcy[5]
    data[const.K] = wcy[6]
    data[const.AURORA] = wcy[7]
    data["node"] = wcy[7]
    data["ip"] = wcy[8]
    data["raw_data"] = raw_string
    return data
659340
def _decode_received(self, msg):
        """"""
        if not isinstance(msg, six.binary_type):
            # already decoded - do nothing
            return msg
        # only decode from utf-8 if message is not binary data
        type = six.byte2int(msg[0:1])
        if type >= 48:  # no binary
            return msg.decode('utf-8')
        # binary message, don't try to decode
        return msg
1241007
def _read_name_text(
            self, bufr, platform_id, encoding_id, strings_offset,
            name_str_offset, length):
        
        raw_name = self._raw_name_string(
            bufr, strings_offset, name_str_offset, length
        )
        return self._decode_name(raw_name, platform_id, encoding_id)
1038162
public function decoded(): ?string
    {
        if (null === $this->user) {
            return null;
        }

        $userInfo = $this->getUser();
        if (null === $this->pass) {
            return $userInfo;
        }

        return $userInfo.':'.$this->getPass();
    }
64619
function decodePubModes(string) {
	var decStr, mode, i, l;
	decStr = decodeString(string);
	mode = {raw : false, merge : false,	distinct : false, command : false};

	if (decStr) {
		l = decStr.length;
		for(i = 0; i < l; i++) {
			if (decStr.charAt(i) === modeValues.RAW) {
				mode.raw = true;
			} else if (decStr.charAt(i) === modeValues.MERGE) {
				mode.merge = true;
			} else if (decStr.charAt(i) === modeValues.DISTINCT) {
				mode.distinct = true;
			} else if (decStr.charAt(i) === modeValues.COMMAND) {
				mode.command = true;
			} else {
				throw new Error('Invalid mode "' + decStr.charAt(i) + '"');
			}

		}
	}
	return mode;
}
365534
def get_user_name(self, uid, return_none_on_error=True):
        
        response = self.raw_command(netfn=0x06, command=0x46, data=(uid,))
        if 'error' in response:
            if return_none_on_error:
                return None
            raise Exception(response['error'])
        name = None
        if 'data' in response:
            data = response['data']
            if len(data) == 16:
                # convert int array to string
                n = ''.join(chr(data[i]) for i in range(0, len(data)))
                # remove padded \x00 chars
                n = n.rstrip("\x00")
                if len(n) > 0:
                    name = n
        return name
1071208
def _as_decode(self, msg):
        """"""
        return {'armed_statuses': [x for x in msg[4:12]],
                'arm_up_states': [x for x in msg[12:20]],
                'alarm_states': [x for x in msg[20:28]]}
237236
def unpad(cls, data):
        
        if sys.version_info > (3, 0):
            return data[:-ord(data[len(data)-1:])].decode()
        else:
            return data[:-ord(data[len(data)-1:])]
515150
def get_users_text(self):
        """"""
        users_text = None
        if self.users_cmd:
            try:
                users_text = self.device.send(self.users_cmd, timeout=60)
            except CommandError:
                self.log('Unable to collect connected users information')
        else:
            self.log('No users command for {}'.format(self.platform))
        return users_text
792485
def get_unicodedata():
    """"""

    import unicodedata

    fail = False
    uver = unicodedata.unidata_version
    path = os.path.join(os.path.dirname(__file__), 'tools')
    fp, pathname, desc = imp.find_module('unidatadownload', [path])
    try:
        unidatadownload = imp.load_module('unidatadownload', fp, pathname, desc)
        unidatadownload.get_unicodedata(uver, no_zip=True)
    except Exception:
        print(traceback.format_exc())
        fail = True
    finally:
        fp.close()

    assert not fail, "Failed to obtain unicodedata!"
    return uver
559046
def _tr_decode(self, msg):
        """"""
        return {'thermostat_index': int(msg[4:6])-1, 'mode': int(msg[6]),
                'hold': msg[7] == '1', 'fan': int(msg[8]),
                'current_temp': int(msg[9:11]), 'heat_setpoint': int(msg[11:13]),
                'cool_setpoint': int(msg[13:15]), 'humidity': int(msg[15:17])}
1016023
def from_raw_message(cls, rawmessage):
        """"""
        empty = cls.create_empty(0x00)
        userdata_dict = cls.normalize(empty, rawmessage)
        return Userdata(userdata_dict)
1142895
def decode(self, pdu):
        """"""
        if _debug: NPCI._debug("decode %s", str(pdu))

        PCI.update(self, pdu)

        # check the length
        if len(pdu.pduData) < 2:
            raise DecodingError("invalid length")

        # only version 1 messages supported
        self.npduVersion = pdu.get()
        if (self.npduVersion != 0x01):
            raise DecodingError("only version 1 messages supported")

        # decode the control octet
        self.npduControl = control = pdu.get()
        netLayerMessage = control & 0x80
        dnetPresent = control & 0x20
        snetPresent = control & 0x08
        self.pduExpectingReply = (control & 0x04) != 0
        self.pduNetworkPriority = control & 0x03

        # extract the destination address
        if dnetPresent:
            dnet = pdu.get_short()
            dlen = pdu.get()
            dadr = pdu.get_data(dlen)

            if dnet == 0xFFFF:
                self.npduDADR = GlobalBroadcast()
            elif dlen == 0:
                self.npduDADR = RemoteBroadcast(dnet)
            else:
                self.npduDADR = RemoteStation(dnet, dadr)

        # extract the source address
        if snetPresent:
            snet = pdu.get_short()
            slen = pdu.get()
            sadr = pdu.get_data(slen)

            if snet == 0xFFFF:
                raise DecodingError("SADR can't be a global broadcast")
            elif slen == 0:
                raise DecodingError("SADR can't be a remote broadcast")

            self.npduSADR = RemoteStation(snet, sadr)

        # extract the hop count
        if dnetPresent:
            self.npduHopCount = pdu.get()

        # extract the network layer message type (if present)
        if netLayerMessage:
            self.npduNetMessage = pdu.get()
            if (self.npduNetMessage >= 0x80) and (self.npduNetMessage <= 0xFF):
                # extract the vendor ID
                self.npduVendorID = pdu.get_short()
        else:
            # application layer message
            self.npduNetMessage = None
884940
def decode(self, data, password=None):
		
		self.password = password
		self.raw = gntp.shim.u(data)
		parts = self.raw.split('\r\n\r\n')
		self.info = self._parse_info(self.raw)
		self.headers = self._parse_dict(parts[0])
980736
function readGetUserItemData(message, tokens) {
	message.userName = protocol.decodeString(tokens[1]);
	readGetItemData(message, tokens.slice(2));
}
390194
def _cr_decode(self, msg):
        """"""
        if int(msg[4:6]) > 0:
            index = int(msg[4:6])-1
            return {'values': [self._cr_one_custom_value_decode(index, msg[6:12])]}
        else:
            part = 6
            ret = []
            for i in range(Max.SETTINGS.value):
                ret.append(self._cr_one_custom_value_decode(i, msg[part:part+6]))
                part += 6
            return {'values': ret}