Added function to check if the message is unicode before trying to convert