<p>Let's say that on the C++ side my function takes a variable of type <code>jstring</code> named <code>myString</code>. I can convert it to an ANSI string as follows:</p>

<pre><code>const char* ansiString = env-&gt;GetStringUTFChars(myString, 0);
</code></pre>

<p>is there a way of getting</p>

<p><code>const wchar_t* unicodeString =</code> ...</p>

A portable and robust solution is to use
iconv
, with the understanding that you have to know what encoding your system
```
wchar_t
```
uses (UTF-16 on Windows, UTF-32 on many Unix systems, for example).
If you want to minimise your dependency on third-party code, you can also hand-roll your own UTF-8 converter. This is easy if converting to UTF-32, somewhat harder with UTF-16 because you have to handle surrogate pairs too. :-P Also, you must be careful to reject
non-shortest
forms, or it can open up security bugs in some cases.