Doh. 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Christian
Biesinger
Sent: Monday, April 23, 2007 11:16 AM
To: [email protected]
Subject: Re: Returning strings from C++ to JS

[EMAIL PROTECTED] wrote:
>       PRUnichar *szRet = (PRUnichar*)NS_Alloc(lstrlen(sz)+2);

Actually the code is wrong even if you define UNICODE. lstrlen doesn't 
return a number of bytes, it returns a number of characters. Therefore, 
you need to multiply its return value by two:

   PRUnichar *szRet = reinterpret_cast<PRUnichar*>(
                                     NS_Alloc(2*lstrlen(sz)+2));



-- 
All the world's a stage,
And all the men and women merely players:
They have their exits and their entrances;
And one man in his time plays many parts, [...]     --W. Shakespeare
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to