title: How to safely convert const char* to const char8_t* in C++20?
body: <p>From <a href="https://stackoverflow.com/a/54842261/673852">this answer</a> I learned that in C++17 we can open <code>std::fstream</code> using a UTF-8 path via <code>std::filesystem::u8path</code>. But in C++20 this function is deprecated, and we are supposed to pass <code>const char8_t*</code> to <code>std::filesystem::path</code> constructor instead.</p>
  
  <p>Here comes the problem: although we can legally convert (via <code>reinterpret_cast</code>) any pointer to <code>const char*</code>, we can't do backwards: from <code>const char*</code> to e.g. <code>const char8_t*</code> (it would break strict aliasing rules). So if we have some external API returning a <code>char</code>-based UTF-8 representation of the filename (e.g. from a library written in C), we can't safely convert the pointer to <code>char8_t</code>-based one.</p>
  
  <p>So, how are we supposed to convert such <code>char</code>-based view of UTF-8 strings to <code>char8_t</code>-based view of them?</p>