#include "precompiled.h" #include "StringConvert.h" #include "lib/types.h" #include "scripting/SpiderMonkey.h" #if SDL_BYTE_ORDER == SDL_BIG_ENDIAN #define ucs2le_to_wchart(ptr) (wchar_t)( (u16) ((u8*)ptr)[0] | (u16) ( ((u8*)ptr)[1] << 8) ) #else #define ucs2le_to_wchart(ptr) (wchar_t)(*ptr); #endif JSString* StringConvert::wchars_to_jsstring(JSContext* cx, const wchar_t* chars, size_t len) { if (len == 0) return JSVAL_TO_STRING(JS_GetEmptyStringValue(cx)); jschar* data = (jschar*)JS_malloc(cx, len*sizeof(jschar)); if (!data) return NULL; // Copy the string data, doing wchar_t->jschar conversion (since they're not equal in GCC) for (size_t i=0; i