result = NewLocale(xpLocale.GetUnicode(), &mSystemLocale);
result = NewLocale(xpLocale.get(), &mSystemLocale);
nsLocaleService::nsLocaleService(void):	mSystemLocale(nsnull), mApplicationLocale(nsnull){	NS_INIT_REFCNT();#if defined(XP_WIN)	nsIWin32Locale*	win32Converter;	nsString		xpLocale;	nsresult result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID,						NULL,kIWin32LocaleIID,(void**)&win32Converter);	NS_ASSERTION(win32Converter!=NULL,"nsLocaleService: can't get win32 converter\n");	if (NS_SUCCEEDED(result) && win32Converter!=nsnull) {				//		// get the system LCID		//		LCID win_lcid = GetSystemDefaultLCID();		if (win_lcid==0) { win32Converter->Release(); return;}		result = win32Converter->GetXPLocale(win_lcid,&xpLocale);		if (NS_FAILED(result)) { win32Converter->Release(); return;}		result = NewLocale(xpLocale.GetUnicode(), &mSystemLocale);		if (NS_FAILED(result)) { win32Converter->Release(); return;}		//		// get the application LCID		//		win_lcid = GetUserDefaultLCID();		if (win_lcid==0) { win32Converter->Release(); return;}		result = win32Converter->GetXPLocale(win_lcid,&xpLocale);		if (NS_FAILED(result)) { win32Converter->Release(); return;}		result = NewLocale(xpLocale.GetUnicode(), &mApplicationLocale);		if (NS_FAILED(result)) { win32Converter->Release(); return;}			win32Converter->Release();	}#endif#if defined(XP_UNIX) || defined(XP_BEOS)    nsIPosixLocale* posixConverter;    nsAutoString xpLocale, platformLocale;    nsresult result = nsComponentManager::CreateInstance(kPosixLocaleFactoryCID,                           NULL,kIPosixLocaleIID,(void**)&posixConverter);    if (NS_SUCCEEDED(result) && posixConverter!=nsnull) {        nsAutoString category, category_platform;        nsLocale* resultLocale;        int i;        resultLocale = new nsLocale();        if ( resultLocale == NULL ) {             posixConverter->Release();             return;         }        for( i = 0; i < LocaleListLength; i++ ) {            char* lc_temp = nsCRT::strdup(setlocale(posix_locale_category[i],""));            category.AssignWithConversion(LocaleList[i]);            category_platform.AssignWithConversion(LocaleList[i]);            category_platform.Append(NS_LITERAL_STRING("##PLATFORM"));            if (lc_temp != nsnull) {                result = posixConverter->GetXPLocale(lc_temp,&xpLocale);                platformLocale.AssignWithConversion(lc_temp);            } else {                char* lang = getenv("LANG");                if ( lang == nsnull ) {                    nsCAutoString langcstr("en-US");                    platformLocale.AssignWithConversion("en_US");	            lang = langcstr.ToNewCString();                    result = posixConverter->GetXPLocale(lang,&xpLocale);                    nsCRT::free(lang); 	        }                else {                    result = posixConverter->GetXPLocale(lang,&xpLocale);                     platformLocale.AssignWithConversion(lang);                }            }            if (NS_FAILED(result)) {                posixConverter->Release();                nsCRT::free(lc_temp);                return;            }            resultLocale->AddCategory(category.GetUnicode(),xpLocale.GetUnicode());            resultLocale->AddCategory(category_platform.GetUnicode(),platformLocale.GetUnicode());            nsCRT::free(lc_temp);        }        (void)resultLocale->QueryInterface(kILocaleIID,(void**)&mSystemLocale);        (void)resultLocale->QueryInterface(kILocaleIID,(void**)&mApplicationLocale);        posixConverter->Release();    }  // if ( NS_SUCCEEDED )...       #endif // XP_UNIX || XP_BEOS#if defined(XP_OS2)    nsCOMPtr<nsIOS2Locale> os2Converter;    nsAutoString xpLocale;    nsresult result = nsComponentManager::CreateInstance(kOS2LocaleFactoryCID,                           NULL,kIOS2LocaleIID,(void**)getter_AddRefs(os2Converter));    if (NS_SUCCEEDED(result) && os2Converter!=nsnull) {        nsAutoString category;        nsLocale* resultLocale;        int i;        resultLocale = new nsLocale();        if ( resultLocale == NULL ) {             return;         }        LocaleObject locale_object = NULL;        UniCreateLocaleObject(UNI_UCS_STRING_POINTER,                              (UniChar *)L"", &locale_object);        char* lc_temp;        for( i = 0; i < LocaleListLength; i++ ) {            lc_temp = nsnull;            UniQueryLocaleObject(locale_object,                                 posix_locale_category[i],                                 UNI_MBS_STRING_POINTER,                                 (void **)&lc_temp);            category.AssignWithConversion(LocaleList[i]);            if (lc_temp != nsnull)                result = os2Converter->GetXPLocale(lc_temp,&xpLocale);            else {                char* lang = getenv("LANG");                if ( lang == nsnull ) {                    nsCAutoString langcstr("en-US");	            lang = langcstr.ToNewCString();                    result = os2Converter->GetXPLocale(lang,&xpLocale);                    nsCRT::free(lang); 	        }                else                    result = os2Converter->GetXPLocale(lang,&xpLocale);             }            if (NS_FAILED(result)) {                nsCRT::free(lc_temp);                return;            }            resultLocale->AddCategory(category.GetUnicode(),xpLocale.GetUnicode());            UniFreeMem(lc_temp);        }        UniFreeLocaleObject(locale_object);        (void)resultLocale->QueryInterface(kILocaleIID,(void**)&mSystemLocale);        (void)resultLocale->QueryInterface(kILocaleIID,(void**)&mApplicationLocale);    }  // if ( NS_SUCCEEDED )...#endif#ifdef XP_MAC	long script = GetScriptManagerVariable(smSysScript);	long lang = GetScriptVariable(smSystemScript,smScriptLang);	long region = GetScriptManagerVariable(smRegionCode);	nsCOMPtr<nsIMacLocale> macConverter;	nsresult result = nsComponentManager::CreateInstance(kMacLocaleFactoryCID,						NULL,kIMacLocaleIID,(void**)getter_AddRefs(macConverter));	if (NS_SUCCEEDED(result) && macConverter!=nsnull) {		nsString xpLocale;		result = macConverter->GetXPLocale((short)script,(short)lang,(short)region,&xpLocale);		if (NS_SUCCEEDED(result)) {			result = NewLocale(xpLocale.GetUnicode(),&mSystemLocale);			if (NS_SUCCEEDED(result)) {				mApplicationLocale = mSystemLocale;				mApplicationLocale->AddRef();			}		}	}#endif}