title: Why can I not read a UTF-16 file longer than 4094 characters?
body: <p><strong>Some information:</strong></p>
  
  <ul>
  <li>I've only tried this on Linux</li>
  <li>I've tried both with GCC (7.2.0) and Clang (3.8.1)</li>
  <li>It requires C++11 or higher to my understanding</li>
  </ul>
  
  <p><strong>What happens when I run it</strong></p>
  
  <p>I get the expected string "abcd" repeated until it hits the position of 4094 characters. After that all it outputs is this sign "?" until the end of the file.</p>
  
  <p><strong>What do I think about this?</strong></p>
  
  <p>I think this is not the expected behavior and that it must be a bug somewhere.</p>
  
  <p><strong>Code you can test with:</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;locale&gt;
  #include &lt;codecvt&gt;
  
  void createTestFile() {
    std::ofstream file ("utf16le.txt", std::ofstream::binary);
    if (file.is_open()) {
      uint16_t bom = 0xFEFF; // UTF-16 little endian BOM
      uint64_t abcd = 0x0064006300620061; // UTF-16 "abcd" string
      file.write((char*)&amp;bom,2);
      for (size_t i=0; i&lt;2000; i++) {
        file.write((char*)&amp;abcd,8);
      }
      file.close();
    }
  }
  
  int main() {
    //createTestFile(); // uncomment to make the test file
  
    std::wifstream file;
    std::wstring line;
  
    file.open("utf16le.txt");
    file.imbue(std::locale(file.getloc(), new std::codecvt_utf16&lt;wchar_t, 0x10ffff, std::consume_header&gt;));
    if (file.is_open()) {
      while (getline(file,line)) {
        std::wcout &lt;&lt; line &lt;&lt; std::endl;
      }
    }
  }
  </code></pre>