Integration of the case conversion interface.

This commit is contained in:
nhotta%netscape.com 1999-02-04 02:02:49 +00:00
Родитель 959fbbabcd
Коммит bc366aa8c7
2 изменённых файлов: 10 добавлений и 24 удалений

Просмотреть файл

@ -60,30 +60,20 @@ nsresult nsCollationMac::GetSortKeyLen(const nsCollationStrength strength,
nsresult nsCollationMac::CreateSortKey(const nsCollationStrength strength,
const nsString& stringIn, PRUint8* key, PRUint32* outLen)
{
// temporary implementation, call FE eventually
PRUint32 byteLenIn = stringIn.Length() * sizeof(PRUnichar);
nsAutoString stringNormalized(stringIn);
if (byteLenIn > *outLen) {
*outLen = 0;
byteLenIn = 0;
}
else {
if (mCollation != NULL) {
mCollation->NormalizeString(stringIn);
if (mCollation != NULL && strength != kCollationCaseSensitive) {
mCollation->NormalizeString(stringNormalized);
}
if (strength != kCollationCaseSensitive) {
nsString *stringLower = new nsString(stringIn);
if (NULL == stringLower)
return NS_ERROR_OUT_OF_MEMORY;
stringLower->ToLowerCase();
memcpy((void *) key, (void *) stringLower->GetUnicode(), byteLenIn);
delete stringLower;
}
else {
memcpy((void *) key, (void *) stringIn.GetUnicode(), byteLenIn);
// temporary implementation, call FE eventually
memcpy((void *) key, (void *) stringNormalized.GetUnicode(), byteLenIn);
}
*outLen = byteLenIn;
}
*outLen = byteLenIn;
return NS_OK;
}

Просмотреть файл

@ -54,14 +54,10 @@ nsresult nsCollationWin::Initialize(nsILocale* locale)
nsresult nsCollationWin::GetSortKeyLen(const nsCollationStrength strength,
const nsString& stringIn, PRUint32* outLen)
{
nsString stringNormalized(stringIn);
if (mCollation != NULL && strength == kCollationCaseInSensitive) {
mCollation->NormalizeString(stringNormalized);
}
// Currently, no length change by the normalization.
// API returns number of bytes when LCMAP_SORTKEY is specified
*outLen = LCMapStringW(GetUserDefaultLCID(), LCMAP_SORTKEY,
(LPCWSTR) stringNormalized.GetUnicode(), (int) stringNormalized.Length(), NULL, 0);
(LPCWSTR) stringIn.GetUnicode(), (int) stringIn.Length(), NULL, 0);
return NS_OK;
}
@ -70,7 +66,7 @@ nsresult nsCollationWin::CreateSortKey(const nsCollationStrength strength,
const nsString& stringIn, PRUint8* key, PRUint32* outLen)
{
int byteLen;
nsString stringNormalized(stringIn);
nsAutoString stringNormalized(stringIn);
if (mCollation != NULL && strength == kCollationCaseInSensitive) {
mCollation->NormalizeString(stringNormalized);