title: Reading file made by cmd, results in 3 weird symbols
body: <p>Im using this piece of code to read a file to a string, and its working perfectly with files manually made in notepad, notepad++ or other text editors:   </p>
  
  <pre><code>std::string utils::readFile(std::string file)
  {
      std::ifstream t(file);
      std::string str((std::istreambuf_iterator&lt;char&gt;(t)),
                        std::istreambuf_iterator&lt;char&gt;());
      return str;
  }
  </code></pre>
  
  <p>When I create a file via notepad (or any other editor) and save it to something, I get this result in my program:<br>
  <img src="https://i.gyazo.com/1ac2387f687fb16b0cd8b2cb86d36330.png" alt="ImageShouldBeValid">  </p>
  
  <p>But when I create a file via CMD (example command below), and run my program, I receive an unexpected result:<br>
  <img src="https://i.gyazo.com/f7aae6581cf8d346a94a63bba3eff6b1.png" alt="ImageShouldBeValid">  <code>
      cmd /C "hostname">"C:\Users\Admin\Desktop\lel.txt" &amp; exit
  </code>
  Result:<br>
  <img src="https://i.gyazo.com/723d0429f7e925c4ec9cf18903cf1325.png" alt="ImageShouldBeValid">  </p>
  
  <p>When I open this file generated by CMD (lel.txt), this is the file contents:<br>
  <img src="https://i.gyazo.com/4e9fa5f41f1b809f0c908ed6d9dc3304.png" alt="ImageShouldBeValid">  </p>
  
  <p>If I edit the generated file (lel.txt) with notepad (adding a space to the end of the file), and try running my program again, I get the same weird 3char result.  </p>
  
  <p>What might cause this? How can I read a file made via cmd, correctly?</p>
  
  <p><strong>EDIT</strong><br>
  I changed my command (now using powershell), and added a function I found, named SkipBOM, and now it works:  </p>
  
  <pre><code>powershell -command "hostname | Out-File "C:\Users\Admin\Desktop\lel.txt" -encoding "UTF8""
  </code></pre>
  
  <p>SkipBOM:  </p>
  
  <pre><code>void SkipBOM(std::ifstream &amp;in)
  {
      char test[3] = { 0 };
      in.read(test, 3);
      if ((unsigned char)test[0] == 0xEF &amp;&amp;
          (unsigned char)test[1] == 0xBB &amp;&amp;
          (unsigned char)test[2] == 0xBF)
      {
          return;
      }
      in.seekg(0);
  }
  </code></pre>