michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #include "nsIPlatformCharset.h" michael@0: #include "nsILocaleService.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsReadableUtils.h" michael@0: #include "nsIComponentManager.h" michael@0: #include michael@0: michael@0: int michael@0: main(int argc, const char** argv) michael@0: { michael@0: michael@0: nsCOMPtr platform_charset = michael@0: do_CreateInstance(NS_PLATFORMCHARSET_CONTRACTID); michael@0: if (!platform_charset) return -1; michael@0: michael@0: nsCOMPtr locale_service = michael@0: do_CreateInstance(NS_LOCALESERVICE_CONTRACTID); michael@0: if (!locale_service) return -1; michael@0: michael@0: nsCOMPtr locale; michael@0: nsAutoCString charset; michael@0: nsAutoString category; michael@0: michael@0: nsresult rv = locale_service->GetSystemLocale(getter_AddRefs(locale)); michael@0: if (NS_FAILED(rv)) return -1; michael@0: michael@0: rv = locale->GetCategory(NS_LITERAL_STRING("NSILOCALE_MESSAGES"), category); michael@0: if (NS_FAILED(rv)) return -1; michael@0: michael@0: rv = platform_charset->GetDefaultCharsetForLocale(category, charset); michael@0: if (NS_FAILED(rv)) return -1; michael@0: michael@0: printf("DefaultCharset for %s is %s\n", NS_LossyConvertUTF16toASCII(category).get(), charset.get()); michael@0: michael@0: category.AssignLiteral("en-US"); michael@0: rv = platform_charset->GetDefaultCharsetForLocale(category, charset); michael@0: if (NS_FAILED(rv)) return -1; michael@0: michael@0: printf("DefaultCharset for %s is %s\n", NS_LossyConvertUTF16toASCII(category).get(), charset.get()); michael@0: michael@0: return 0; michael@0: }