How to convert char * to PRUnichar *
I need to pass char*
to an XPCOM function, but this function accepts PRUnichar *
. How to convert from char*
to PRUnichar *
?
Take a look at nsAutoString .
If you have UTF-8 string, you can use NS_ConvertUTF8toUTF16 or CopyUTF8toUTF16. If you have a different encoding you will need to use nsICharsetConverterManager or some other API to convert to something normal: http://mxr.mozilla.org/mozilla-central/source/intl/uconv/idl/nsICharsetConverterManager.idl
The XPCOM chaining manual has a good link to this: https://developer.mozilla.org/En/XPCOM:Strings#Unicode_Conversion_ns CString_vs._nsString
What character set is your char * in?