title: How to compare managed and unmanaged Strings?
body: <p>I have an application that uses managed <code>System::String</code> in the UI elements, but then refers to un-managed (read: legacy) code for the more complex computation.</p>
  
  <p>Additionally, there is not a consistent encoding for the strings - managed strings can be either regular <code>"strings"</code> or Unicode <code>L"strings"</code> and un-managed strings come in all of <code>char *, wchar_t *, std::string, std::wstring</code> varieties.</p>
  
  <p>What is the best way to compare the various flavors of strings? I'm hoping that I can do this without having to implement half a dozen comparison methods like</p>
  
  <pre><code>int compare(System::String ^ s1, char * s2);
  int compare(System::String ^ s1, wchar_t * s2);
  int compare(System::String ^ s1, std::string s2);
  int compare(System::String ^ s1, std::wstring s2);
  int compare(char * s1, System::String ^ s2);
  int compare(wchar_t * s1, System::String ^ s2);
  ...
  </code></pre>
  
  <p>The primary purpose will be equality comparisons, so if those are significantly easier to do, then I would like to see those answers as well.</p>