Ignore:
Timestamp:
Apr 8, 2006, 10:21:52 AM (19 years ago)
Author:
ap
Message:

Reviewed by Darin.

Test: fast/js/string-capitalization.html

  • JavaScriptCore.xcodeproj/project.pbxproj: Added KXMLCore::Unicode headers to the project.
  • icu/unicode/putil.h: Added (copied from WebCore).
  • icu/unicode/uiter.h: Ditto.
  • icu/unicode/ustring.h: Ditto.
  • kjs/string_object.cpp: (StringProtoFunc::callAsFunction): Use the new KXMLCore::Unicode::toUpper() and toLower().
  • kjs/ustring.cpp: Removed unused (and evil) UChar::toLower() and toUpper().
  • kjs/ustring.h: Ditto.
  • kxmlcore/unicode/Unicode.h: Corrected capitalization of the word Unicode.
  • kxmlcore/unicode/UnicodeCategory.h: Renamed include guard macro to match file name.
  • kxmlcore/unicode/icu/UnicodeIcu.h: (KXMLCore::Unicode::toLower): Work on strings, not individual characters. Use ICU root locale. (KXMLCore::Unicode::toUpper): Ditto. (KXMLCore::Unicode::isFormatChar): Use int32_t, which can hold a complete code point. (KXMLCore::Unicode::isSeparatorSpace): Ditto. (KXMLCore::Unicode::category): Ditto.
  • kxmlcore/unicode/qt4/UnicodeQt4.h: (KXMLCore::Unicode::toLower): Work on strings, not individual characters. (KXMLCore::Unicode::toUpper): Ditto. (KXMLCore::Unicode::isFormatChar): Use int32_t, which can hold a complete code point. (KXMLCore::Unicode::isSeparatorSpace): Ditto. (KXMLCore::Unicode::category): Ditto.
  • tests/mozilla/ecma/String/15.5.4.12-1.js: Corrected expected results.
  • tests/mozilla/ecma/String/15.5.4.12-5.js: Corrected expected results.
File:
1 edited

Legend:

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

    r13015 r13740  
    3535#include <stdio.h>
    3636#include "string_object.lut.h"
     37#include <kxmlcore/unicode/Unicode.h>
    3738
    3839using namespace KJS;
     
    624625    break;
    625626  case ToLowerCase:
    626   case ToLocaleLowerCase: // FIXME: To get this 100% right we need to detect Turkish and change I to lowercase i without a dot.
     627  case ToLocaleLowerCase: { // FIXME: See http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt for locale-sensitive mappings that aren't implemented.
    627628    u = s;
    628     for (i = 0; i < len; i++)
    629       u[i] = u[i].toLower();
    630     result = jsString(u);
    631     break;
     629    u.copyForWriting();
     630    uint16_t* dataPtr = reinterpret_cast<uint16_t*>(u.rep()->data());
     631    uint16_t* destIfNeeded;
     632
     633    int len = KXMLCore::Unicode::toLower(dataPtr, u.size(), destIfNeeded);
     634    if (len >= 0)
     635        result = jsString(UString(reinterpret_cast<UChar *>(destIfNeeded ? destIfNeeded : dataPtr), len));
     636    else
     637        result = jsString(s);
     638
     639    free(destIfNeeded);
     640    break;
     641  }
    632642  case ToUpperCase:
    633   case ToLocaleUpperCase: // FIXME: To get this 100% right we need to detect Turkish and change i to uppercase I with a dot.
     643  case ToLocaleUpperCase: { // FIXME: See http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt for locale-sensitive mappings that aren't implemented.
    634644    u = s;
    635     for (i = 0; i < len; i++)
    636       u[i] = u[i].toUpper();
    637     result = jsString(u);
    638     break;
     645    u.copyForWriting();
     646    uint16_t* dataPtr = reinterpret_cast<uint16_t*>(u.rep()->data());
     647    uint16_t* destIfNeeded;
     648
     649    int len = KXMLCore::Unicode::toUpper(dataPtr, u.size(), destIfNeeded);
     650    if (len >= 0)
     651        result = jsString(UString(reinterpret_cast<UChar *>(destIfNeeded ? destIfNeeded : dataPtr), len));
     652    else
     653        result = jsString(s);
     654
     655    free(destIfNeeded);
     656    break;
     657  }
    639658#ifndef KJS_PURE_ECMA
    640659  case Big:
Note: See TracChangeset for help on using the changeset viewer.