localeName = NS_LITERAL_STRING("ja-JP");
localeName.AssignLiteral("ja-JP");
static void Test_nsLocale(){#if defined(XP_MAC) || defined(XP_MACOSX)  nsAutoString localeName;  nsCOMPtr<nsIMacLocale> macLocale;  short script, lang;  nsresult res;  nsCOMPtr<nsIMacLocale> win32Locale = do_CreateInstance(kMacLocaleFactoryCID);  if (macLocale) {    localeName = NS_LITERAL_STRING("en-US");    res = macLocale->GetPlatformLocale(localeName, &script, &lang);    printf("script for en-US is 0\n");    printf("result: script = %d lang = %d\n", script, lang);    localeName = NS_LITERAL_STRING("en-GB");    res = macLocale->GetPlatformLocale(localeName, &script, &lang);    printf("script for en-GB is 0\n");    printf("result: script = %d lang = %d\n", script, lang);    localeName = NS_LITERAL_STRING("fr-FR");    res = macLocale->GetPlatformLocale(localeName, &script, &lang);    printf("script for fr-FR is 0\n");    printf("result: script = %d lang = %d\n", script, lang);    localeName = NS_LITERAL_STRING("de-DE");    res = macLocale->GetPlatformLocale(localeName, &script, &lang);    printf("script for de-DE is 0\n");    printf("result: script = %d lang = %d\n", script, lang);    localeName = NS_LITERAL_STRING("ja-JP");    res = macLocale->GetPlatformLocale(localeName, &script, &lang);    printf("script for ja-JP is 1\n");    printf("result: script = %d lang = %d\n", script, lang);  }#elif defined(XP_WIN) || defined(XP_OS2)  nsAutoString localeName;  LCID lcid;  nsresult res;  nsCOMPtr<nsIWin32Locale> win32Locale = do_CreateInstance(kWin32LocaleFactoryCID);  if (win32Locale) {    localeName = NS_LITERAL_STRING("en-US");    res = win32Locale->GetPlatformLocale(localeName, &lcid);    printf("LCID for en-US is 1033\n");    printf("result: locale = %s LCID = 0x%0.4x %d\n", NS_LossyConvertUCS2toASCII(localeName).get(), lcid, lcid);    localeName = NS_LITERAL_STRING("en-GB");    res = win32Locale->GetPlatformLocale(localeName, &lcid);    printf("LCID for en-GB is 2057\n");    printf("result: locale = %s LCID = 0x%0.4x %d\n", NS_LossyConvertUCS2toASCII(localeName).get(), lcid, lcid);    localeName = NS_LITERAL_STRING("fr-FR");    res = win32Locale->GetPlatformLocale(localeName, &lcid);    printf("LCID for fr-FR is 1036\n");    printf("result: locale = %s LCID = 0x%0.4x %d\n", NS_LossyConvertUCS2toASCII(localeName).get(), lcid, lcid);    localeName = NS_LITERAL_STRING("de-DE");    res = win32Locale->GetPlatformLocale(localeName, &lcid);    printf("LCID for de-DE is 1031\n");    printf("result: locale = %s LCID = 0x%0.4x %d\n", NS_LossyConvertUCS2toASCII(localeName).get(), lcid, lcid);    localeName = NS_LITERAL_STRING("ja-JP");    res = win32Locale->GetPlatformLocale(localeName, &lcid);    printf("LCID for ja-JP is 1041\n");    printf("result: locale = %s LCID = 0x%0.4x %d\n", NS_LossyConvertUCS2toASCII(localeName).get(), lcid, lcid);  }#else  nsAutoString localeName;  char locale[32];  size_t length = 32;  nsresult res;  nsCOMPtr<nsIPosixLocale> posixLocale = do_CreateInstance(kPosixLocaleFactoryCID);  if (posixLocale) {    localeName = NS_LITERAL_STRING("en-US");    res = posixLocale->GetPlatformLocale(localeName, locale, length);    printf("result: locale = %s POSIX = %s\n", NS_LossyConvertUCS2toASCII(localeName).get(), locale);    localeName = NS_LITERAL_STRING("en-GB");    res = posixLocale->GetPlatformLocale(localeName, locale, length);    printf("result: locale = %s POSIX = %s\n", NS_LossyConvertUCS2toASCII(localeName).get(), locale);    localeName = NS_LITERAL_STRING("fr-FR");    res = posixLocale->GetPlatformLocale(localeName, locale, length);    printf("result: locale = %s POSIX = %s\n", NS_LossyConvertUCS2toASCII(localeName).get(), locale);    localeName = NS_LITERAL_STRING("de-DE");    res = posixLocale->GetPlatformLocale(localeName, locale, length);    printf("result: locale = %s POSIX = %s\n", NS_LossyConvertUCS2toASCII(localeName).get(), locale);    localeName = NS_LITERAL_STRING("ja-JP");    res = posixLocale->GetPlatformLocale(localeName, locale, length);    printf("result: locale = %s POSIX = %s\n", NS_LossyConvertUCS2toASCII(localeName).get(), locale);  }  else {    printf("Fail: CreateInstance PosixLocale\n");  }#endif}