- JSLock lock;
-
- size_t length = strlen(string);
- Vector< ::UChar, 1024> buffer(length);
- ::UChar* p = buffer.data();
- if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length))
- return 0;
-
- return toRef(UString(reinterpret_cast<KJS::UChar*>(buffer.data()), p - buffer.data()).rep()->ref());
+ initializeThreading();
+ if (string) {
+ size_t length = strlen(string);
+ Vector<UChar, 1024> buffer(length);
+ UChar* p = buffer.data();
+ if (conversionOK == convertUTF8ToUTF16(&string, string + length, &p, p + length))
+ return OpaqueJSString::create(buffer.data(), p - buffer.data()).leakRef();
+ }
+
+ // Null string.
+ return OpaqueJSString::create().leakRef();