code: def _encodeAddressField(address, smscField=False):
      
      # First, see if this is a number or an alphanumeric string
      toa = 0x80 | 0x00 | 0x01 # Type-of-address start | Unknown type-of-number | ISDN/tel numbering plan
      alphaNumeric = False    
      if address.isalnum():
          # Might just be a local number
          if address.isdigit():
              # Local number
              toa |= 0x20
          else:
              # Alphanumeric address
              toa |= 0x50
              toa &= 0xFE # switch to "unknown" numbering plan
              alphaNumeric = True
      else:
          if address[0] == '+' and address[1:].isdigit():
              # International number
              toa |= 0x10
              # Remove the '+' prefix
              address = address[1:]
          else:
              # Alphanumeric address
              toa |= 0x50
              toa &= 0xFE # switch to "unknown" numbering plan
              alphaNumeric = True
      if  alphaNumeric:
          addressValue = packSeptets(encodeGsm7(address, False))
          addressLen = len(addressValue) * 2        
      else:
          addressValue = encodeSemiOctets(address)
          if smscField:            
              addressLen = len(addressValue) + 1
          else:
              addressLen = len(address)
      result = bytearray()
      result.append(addressLen)
      result.append(toa)
      result.extend(addressValue)
      return result
docs: Encodes the address into an address field
      
      :param address: The address to encode (phone number or alphanumeric)
      :type byteIter: str
      
      :return: Encoded SMS PDU address field
      :rtype: bytearray