title: How to detect if a text is base64 encoded or is a plain text.? ( C, Linux)
body: <p>I'm having issues with an email client that I'm working on, basically when I fetch an email I have to decode it via base64 tools, I have automated the process by directly downloading unseen new emails and then it is auto decoded and gives me the actual email text or attachment, but the problem is that some emails to my gmail accounts are in plain text and html which when automatically decoded gives me just empty files instead of the plain text.</p>
  
  <p>So i want to know if there is any way by which i can detect the text format before trying to decode it, because decoding a simple plain text or html actually corrupts the data.</p>
  
  <p>This would help me decode only those emails which is base64 encoded instead of decoding every and all emails that i fetch from my gmail account.</p>
  
  <p>I'm on linux, doing it in C and shell.</p>
  
  <p>Would really appreciate your help.</p>
  
  <blockquote>
    <p>Edit: I fetch only one unseen email (Body, one or two sections
    excluding headers) at a time, but after fetching i have to decode it
    to a plain text or a multimedia file, it works fine, but one email in
    10 is actually not base64 encoded and is a simple plain text while my
    program decodes every email it fetches, so that one email which is
    plain text and not base64 encoded ends up as some empty file... </p>
    
    <p>So I want to skip decoding that email which is simple plain text and
    not base64 text.</p>
  </blockquote>