When you allocate memory with nsMemory::Alloc(), the parameter you pass, does it represent the size of the memory in bytes or the size of the memory in 16-bits chunks (2 bytes)?
Bytes. It is not only used for unicode strings...
PRUnichar *unicharString = reinterpret_cast<PRUnichar*>(nsMemory::Alloc(strlen(charString) * 2) ; // strlen * 2 because of 16 bits per character
add 1! you need space for a terminating zero.
What charset is your string in? ToNewUnicode or UTF8ToNewUnicode may be useful for you; or, if you have a filename, NS_CopyNativeToUnicode.
_______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom
