lang = langcstr.ToNewCString();
lang = ToNewCString(langcstr);
nsLocaleService::nsLocaleService(void):	mSystemLocale(nsnull), mApplicationLocale(nsnull){	NS_INIT_REFCNT();#if defined(XP_WIN)    nsresult result;	nsCOMPtr<nsIWin32Locale> win32Converter        = do_CreateInstance(NS_WIN32LOCALE_CONTRACTID, &result);	nsString		xpLocale;	NS_ASSERTION(win32Converter!=NULL,"nsLocaleService: can't get win32 converter\n");	if (NS_SUCCEEDED(result) && win32Converter) {				//		// get the system LCID		//		LCID win_lcid = GetSystemDefaultLCID();		if (win_lcid==0) { return;}		result = win32Converter->GetXPLocale(win_lcid,&xpLocale);		if (NS_FAILED(result)) { return;}		result = NewLocale(xpLocale.get(), &mSystemLocale);		if (NS_FAILED(result)) { return;}		//		// get the application LCID		//		win_lcid = GetUserDefaultLCID();		if (win_lcid==0) { return;}		result = win32Converter->GetXPLocale(win_lcid,&xpLocale);		if (NS_FAILED(result)) { return;}		result = NewLocale(xpLocale.get(), &mApplicationLocale);		if (NS_FAILED(result)) { return;}	}#endif#if defined(XP_UNIX) || defined(XP_BEOS)    nsresult result;    nsCOMPtr<nsIPosixLocale> posixConverter =        do_CreateInstance(NS_POSIXLOCALE_CONTRACTID, &result);    nsAutoString xpLocale, platformLocale;    if (NS_SUCCEEDED(result) && posixConverter) {        nsAutoString category, category_platform;        nsLocale* resultLocale;        int i;        resultLocale = new nsLocale();        if ( resultLocale == NULL ) {             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)) {                nsCRT::free(lc_temp);                return;            }            resultLocale->AddCategory(category.get(),xpLocale.get());            resultLocale->AddCategory(category_platform.get(),platformLocale.get());            nsCRT::free(lc_temp);        }        (void)resultLocale->QueryInterface(NS_GET_IID(nsILocale),(void**)&mSystemLocale);        (void)resultLocale->QueryInterface(NS_GET_IID(nsILocale),(void**)&mApplicationLocale);    }  // if ( NS_SUCCEEDED )...       #endif // XP_UNIX || XP_BEOS#if defined(XP_OS2)    nsresult result;    nsCOMPtr<nsIOS2Locale> os2Converter        = do_CreateInstance(NS_OS2LOCALE_CONTRACTID, &result);    nsAutoString xpLocale;    if (NS_SUCCEEDED(result) && os2Converter) {        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.get(),xpLocale.get());            UniFreeMem(lc_temp);        }        UniFreeLocaleObject(locale_object);        (void)resultLocale->QueryInterface(NS_GET_IID(nsILocale),(void**)&mSystemLocale);        (void)resultLocale->QueryInterface(NS_GET_IID(nsILocale),(void**)&mApplicationLocale);    }  // if ( NS_SUCCEEDED )...#endif#ifdef XP_MAC	long script = GetScriptManagerVariable(smSysScript);	long lang = GetScriptVariable(smSystemScript,smScriptLang);	long region = GetScriptManagerVariable(smRegionCode);    nsresult result;	nsCOMPtr<nsIMacLocale> macConverter        = do_CreateInstance(NS_MACLOCALE_CONTRACTID, &result);	if (NS_SUCCEEDED(result) && macConverter) {		nsString xpLocale;		result = macConverter->GetXPLocale((short)script,(short)lang,(short)region,&xpLocale);		if (NS_SUCCEEDED(result)) {			result = NewLocale(xpLocale.get(),&mSystemLocale);			if (NS_SUCCEEDED(result)) {				mApplicationLocale = mSystemLocale;				mApplicationLocale->AddRef();			}		}	}#endif}