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 *

?

+2


source to share


3 answers


Take a look at nsAutoString .



+3


source


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

+2


source


What character set is your char * in?

+1


source







All Articles