Mozilla does not export any frozen APIs to convert from |const nsAString::char_type*| to |const char*|. if you are writing your code to work only on Win32, then you can use the WideCharToMultiByte system call, or you can write your own code to convert from UTF-16 to a narrow character encoding of your choice. if you know you are only dealing with ASCII data, then you can simply write out every other byte ;-)

Darin



Abhilash Maniam wrote:
Hi,

I am trying to extract the contents of the DOM document and write to a text file in ASCII.

I tried using the strdup but the compiler complains "cannot convert parameter 1 from 'const nsAString::char_type *' to 'const char *'"
if I use strdup(name.get()) where name is nsEmbedString.


What are the other ways of converting from the EmbedString type to an ASCII type for writing?

Thank you.
Abhilash




L. David Baron wrote:


On Friday 2003-08-01 01:15 -0600, Abhilash Maniam wrote:

I have Gecko-sdk 1.4 for windows and am using Visual C++ .NET. What is the library that I have to link against for ToNewCString?

I have the following lines in my code:

 nsEmbedString name;
 char *str;
 domDocument->GetLocalName(name);
 str = ToNewCString(name);



|ToNewCString| is not a frozen API. Perhaps you'd be better off using |strdup(name.get())|? (Or, if using the right allocator is an issue, maybe using nsMemory::Alloc and then strcpy? Or do you even need the copy at all?)

-David






Reply via email to