Title pretty much says it all. I have a string of text which occasionally is encoded base64. The way I am currently detecting if the string is encoded or not seems a bit of a hack and I was wondering if there was a more reliable (proper) approach. Right now, I am checking if it is a very "long" continuous string of characters and the number of characters in the string is a multiple of 4. If so, then I send it though MIME:Base64's decode_base64(). Any suggestions?