I’m currently working on a project to embed JSCore (chosen
since I was fairly familiar with it, it was C++, and its blazing fast on
Windows) into an app to replace Perl as the company I work for’s language
of choice for quick and dirty scripting. Since we have a massive library of Win32
code to use with it, I was wondering:
Is there a quick way to convert a KJS::UString to an array
of Unicode shorts (aka LPCWSTR in Win32 speak).
I came up with the much hackish solution below that works,
but seems to me to be really inefficient:
// Convert from UString to LPCWSTR.
// FIXME: Find a better solution if possible
// TODO: Convert into global C style function if above
FIXME becomes invalidated
const UChar* data = ustring.data();
int length = ustring.size();
WCHAR* winstringp = new WCHAR[length+1];
ZeroMemory(winstring,
(sizeof(WCHAR)*length+1));
for( int i = 0; i
< length; i++) winstrinpg[i] = data[i].unicode();
winstringp[length] = '\0';
LPCWSTR
winstring = winstringp;
If
someone can think of a better way, that would be totally awesome.
Justin
Haygood | Software Engineer | EyeWonder, Inc.
Phone: 678-891-2031 Cell: 404-271-2273 (jhaygood86@tmomail.net)
jhaygood@eyewonder.com
EyeWonder
Richer Media. Richer Results.
www.eyewonder.com