[EMAIL PROTECTED] wrote:
Can anybody tell me how to convert an int value to a nsEmbedString?
I need to use this to set the value of a DOM progress bar:
mProgressBar->SetAttribute("value", "45%");
// the way I did this in earlier
TCHAR szValue[5];
wsprintf(szValue, TEXT("%li%%"), *Value);
mProgressBar->SetAttribute(NS_LITERAL_STRING("value"),
NS_ConvertUTF8toUCS2(szValue));
Are you compiling with _UNICODE defined or not? I can't see how this would
compile properly, since you have a wide-char buffer, but you're treating it
as UTF8 (which is a narrow-char buffer).
But now I need to use fronzen string API with nsEmbedString, which does
not offer NS_ConvertUTF8toUCS2.
How can I construct an nsEmbedString with an int plus "%".
If your code is windows-only:
wchar wValue[10];
wsprintf(wValue, L"%li%%"), myint32);
mProgressBar->SetAttribute(NS_LITERAL_STRING("value"),
nsDependentString(wValue));
If your code needs to be cross-platform (wsprintf not available):
char cValue[10];
sprintf(cValue, "%i%%", myint32);
nsEmbedString wide;
NS_CStringToUTF16(nsDependentCString(cValue), NS_CSTRING_ENCODING_ASCII, wide);
mProgressBar->SetAttribute(NS_LITERAL_STRING("value"), wide);
--BDS
_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom