title: What is the equivalent of char(0) or '\0' for wchar_t?
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;locale&gt;
  
  int main(int argc, char** argv) {
      std::wcout.imbue(std::locale("zh_CN.UTF-8"));
  
      std::wcout &lt;&lt; wchar_t(0) &lt;&lt; L"哈哈" &lt;&lt; std::endl;
      std::cout &lt;&lt; char(0) &lt;&lt; "haha" &lt;&lt; std::endl;
      std::cout &lt;&lt; "---------------" &lt;&lt; std::endl;
  
      std::wcout.clear();
      std::wcout &lt;&lt; L"哈哈" &lt;&lt; std::endl;
      std::cout &lt;&lt; "haha" &lt;&lt; std::endl;
      std::cout &lt;&lt; "---------------" &lt;&lt; std::endl;
  
      std::wcout &lt;&lt; L'\0' &lt;&lt; L"哈哈" &lt;&lt; std::endl;
      std::cout &lt;&lt; '\0' &lt;&lt; "haha" &lt;&lt; std::endl;
      std::cout &lt;&lt; "---------------" &lt;&lt; std::endl;
  
      std::wcout.clear();
      std::wcout &lt;&lt; L"哈哈" &lt;&lt; std::endl;
      std::cout &lt;&lt; "haha" &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>The <code>wchar_t(0)</code> and <code>L'\0'</code> seem to different from <code>char(0)</code> and <code>'\0'</code> and cause the <code>ostream</code> to have bad state. </p>
  
  <p>It took me some time to figure out the missing output is not caused by the locale setting but the <code>wchar_t</code> since my original program has somewhere output a <code>wchar_t(0)</code> or <code>'\0'</code>.</p>
  
  <p>My question is how are they different from the <code>char</code> version? And how to correctly use an empty <code>wchar_t</code>?</p>
  
  <p>Thanks in advance.</p>