code: def decodeSemiOctets(encodedNumber, numberOfOctets=None):
      
      number = []
      if type(encodedNumber) in (str, bytes):
          encodedNumber = bytearray(codecs.decode(encodedNumber, 'hex_codec'))
      i = 0
      for octet in encodedNumber:        
          hexVal = hex(octet)[2:].zfill(2)   
          number.append(hexVal[1])
          if hexVal[0] != 'f':
              number.append(hexVal[0])
          else:
              break
          if numberOfOctets != None:
              i += 1
              if i == numberOfOctets:
                  break
      return ''.join(number)
docs: Semi-octet decoding algorithm(e.g. for phone numbers)
      
      :param encodedNumber: The semi-octet-encoded telephone number (in bytearray format or hex string)
      :type encodedNumber: bytearray, str or iter(bytearray)
      :param numberOfOctets: The expected amount of octets after decoding (i.e. when to stop)
      :type numberOfOctets: int
      
      :return: decoded telephone number
      :rtype: string