title: setlocale() doesn't work in iOS simulator?
body: <p>Update: Strangely, setlocale() only fails on the iOS Simulator so I have amended the question title. It works fine on actual devices.</p>
  
  <p>I'm working with native (C/C++) code under iOS 6 and I need to format arbitrary <code>wchar_t</code> strings. However, when formatting strings containing codepoints outside the Latin-1 codepage, <code>swprintf</code> fails (return value -1 with errno=<code>EILSEQ</code>).</p>
  
  <pre><code>wchar_t buff[256];
  swprintf(buff, 256, L"\u00A9 %ls", L"ascii"); // works
  swprintf(buff, 256, L"\u03A0 %ls", L"ascii"); // will return -1
  </code></pre>
  
  <p>After asking a related question <a href="https://stackoverflow.com/questions/15438968/vswprintf-fails-for-certain-unicode-codepoints-under-mac-os-x">here</a>, the problem appears to be that the locale is not set correctly (I have verified that the solution works under Mac OS X). But it seems to have no effect under iOS 6:</p>
  
  <pre><code>#include &lt;locale.h&gt;
  
  setlocale(LC_CTYPE,"");
  </code></pre>
  
  <p>Following the instructions <a href="http://yui.co/setlocale-in-ios-aka-swprintf-in-ios/" rel="nofollow noreferrer">here</a> , I have copied/added the locale files manually to my project, and set the <code>PATH_LOCALE</code> environment variable, but the problem persists:</p>
  
  <pre><code>NSString* resourcePath=[[NSBundle mainBundle] resourcePath];
  setenv("PATH_LOCALE", [resourcePath UTF8String], 1);
  setlocale(LC_CTYPE,"en_US.UTF-8");
  </code></pre>
  
  <p>Does anyone know how I can get setlocale() to work under iOS 6 (while still having the app accepted by the Apple Store)?</p>