Vasiliy Stepanov wrote:
How can I convert form PRUnichar* or nsAString to std::string? Is there any
method?
Since I am writing exactly such a routine when I saw your post,
I think I will share it with everybody.
string MOZStringConvert(nsEmbedString s)
{
PRUnichar *start = (PRUnichar *)s.get();
PRUnichar *end = (PRUnichar *)s.get() + s.Length();
wchar_t wca[4096];
wchar_t *wstart = wca;
wchar_t *wpr = wstart;
for(; start < end; ++start)
{
*wstart = (wchar_t) *start;
++wstart;
}
*wstart = 0;
string ptr;
ptr.resize(4096);
size_t size = wcstombs((char*)ptr.data(), wpr, 4096);
ptr.resize(size);
return ptr;
}
Steve
_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom