My situation is the following: I have a const char* string that I need to pass to a method that requires a nsAString& (that method is nsIDOMCharacterData::InsertData(PRUInt32 offset, const nsAString& arg)). However, when I try, it refuses to compile. Here's the snippet :
/************* BEGIN SNIPPET *********************************/ nsIDOMText* aTextNode ; // already initialized PRUInt32 anOffset = 1 ;
const char* mbString = "Test string" ; /* the const char* is actually a parameter of the current method */
PRUnichar* wcString = (PRUnichar*)nsMemory::Alloc(strlen(mbString)+1);
mbstowcs(wcString,mbString,strlen(mbString)) ; /* converts the char* to PRUnichar* */
aTextNode->InsertData(anOffset,nsDependentString(wcString)) ;
/************** END SNIPPET ********************************/
When I try this, I get the following error :
error C2440: 'type cast' : cannot convert from 'PRUnichar *' to 'nsDependentString'
What am I doing wrong? I've seen several places in the Mozilla code where the same operation is being done (one of the oh so many can be found at http://lxr.mozilla.org/seamonkey/source/editor/composer/src/nsEditorSpellCheck.cpp#253), I just don't see why their code works and not mine.
Thanks a lot.
A. _______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom
