Ignore:
Timestamp:
May 13, 2008, 2:46:47 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Geoffrey Garen.

<rdar://problem/4949018> JavaScriptCore API claims to work with UTF8 strings, but only works
with ASCII strings


  • kjs/ustring.h:
  • kjs/ustring.cpp: (KJS::UString::Rep::createFromUTF8): Added. Implementation adapted from JSStringCreateWithUTF8CString().
  • API/JSStringRef.cpp: (JSStringCreateWithUTF8CString):
  • API/JSClassRef.cpp: (OpaqueJSClass::OpaqueJSClass): Use UString::Rep::createFromUTF8().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ustring.cpp

    r32609 r33374  
    237237  // steal the single reference this Rep was created with
    238238  return adoptRef(r);
     239}
     240
     241PassRefPtr<UString::Rep> UString::Rep::createFromUTF8(const char* string)
     242{
     243    if (!string)
     244        return &UString::Rep::null;
     245
     246    size_t length = strlen(string);
     247    Vector<UChar, 1024> buffer(length);
     248    UChar* p = buffer.data();
     249    if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length))
     250        return &UString::Rep::null;
     251
     252    return UString::Rep::createCopying(buffer.data(), p - buffer.data());
    239253}
    240254
Note: See TracChangeset for help on using the changeset viewer.