title: How do I properly use std::string on UTF-8 in C++?
body: <p>My platform is a Mac. I'm a C++ beginner and working on a personal project which processes Chinese and English. UTF-8 is the preferred encoding for this project.</p>
  <p>I read some posts on Stack Overflow, and many of them suggest using <code>std::string</code> when dealing with UTF-8 and avoid <code>wchar_t</code> as there's no <code>char8_t</code> right now for UTF-8.</p>
  <p>However, none of them talk about how to properly deal with functions like <code>str[i]</code>, <code>std::string::size()</code>, <code>std::string::find_first_of()</code> or <code>std::regex</code> as these function usually returns unexpected results when facing UTF-8.</p>
  <p>Should I go ahead with <code>std::string</code> or switch to <code>std::wstring</code>? If I should stay with <code>std::string</code>, what's the best practice for one to handle the above problems?</p>