title: Char string encoding differences between native C++ and C++/CLI?
body: <p>I have a strange problem for which I believe there is a solution but I cannot find it. Your help would be appreciated.</p>
  
  <p>On the one hand, I have a <em>native C++</em> class named <code>Native</code> which has a static <code>wchar_t</code> array containing accentuated characters. This array is const and defined at build time.</p>
  
  <pre><code>/// Header file
  Native
  {
  public:
      static const wchar_t* Array() const { return mArray; }
  
  private:
      static const wchar_t *mArray;
  };
  
  //--------------------------------------------------------------
  
  /// .cpp file
  const wchar_t* Native::mArray = {L"This is a description éàçï"};
  </code></pre>
  
  <p>On the other hand, I have a C++/CLI class that uses the array like this:</p>
  
  <pre><code>/// C++/CLI use
  System::String^ S1 = gcnew System::String( Native::Array() );
  System::String^ S2 = gcnew System::String( L"This is a description éàçï" };
  </code></pre>
  
  <p>The problem is that while <code>S2</code> gives <strong>This is a description éàçï</strong> as expected, <code>S1</code> gives <strong>This is a description Ã©Ã Ã§Ã¯</strong>. I do not understand why passing a pointer to a static array will not give the same result as giving the same array directly???</p>
  
  <p>I guess this is an encoding problem but I would have expected the same results for both <code>S1</code> and <code>S2</code>. Do you know how to solve the problem? The way I must use it in my program is like <code>S1</code> i.e. by accessing the build time static array with a static method that returns a const wchar_t*.</p>
  
  <p>Thanks for your help!</p>
  
  <hr>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>What is the best way to define literals at build time in C++ using Intel C++ 13.0 to make them directly usable in C++/CLI System::String constructor? This could be the ultimate question for my problem.</p>