2003-07-23 03:46:38 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-08-26 02:05:28 +04:00
|
|
|
#include "nsIPlatformCharset.h"
|
|
|
|
#include "nsILocaleService.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2001-09-29 12:28:41 +04:00
|
|
|
#include "nsReadableUtils.h"
|
1999-08-26 02:05:28 +04:00
|
|
|
#include "nsLocaleCID.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, const char** argv)
|
|
|
|
{
|
2003-10-30 08:04:45 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPlatformCharset> platform_charset =
|
|
|
|
do_CreateInstance(NS_PLATFORMCHARSET_CONTRACTID);
|
|
|
|
if (!platform_charset) return -1;
|
|
|
|
|
|
|
|
nsCOMPtr<nsILocaleService> locale_service =
|
2007-09-05 17:04:54 +04:00
|
|
|
do_CreateInstance(NS_LOCALESERVICE_CONTRACTID);
|
2003-10-30 08:04:45 +03:00
|
|
|
if (!locale_service) return -1;
|
|
|
|
|
2003-07-23 03:46:38 +04:00
|
|
|
nsCOMPtr<nsILocale> locale;
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString charset;
|
2003-10-30 08:04:45 +03:00
|
|
|
nsAutoString category;
|
1999-08-26 02:05:28 +04:00
|
|
|
|
2003-10-30 08:04:45 +03:00
|
|
|
nsresult rv = locale_service->GetSystemLocale(getter_AddRefs(locale));
|
2003-07-23 03:46:38 +04:00
|
|
|
if (NS_FAILED(rv)) return -1;
|
1999-08-26 02:05:28 +04:00
|
|
|
|
2003-10-30 08:04:45 +03:00
|
|
|
rv = locale->GetCategory(NS_LITERAL_STRING("NSILOCALE_MESSAGES"), category);
|
2003-07-23 03:46:38 +04:00
|
|
|
if (NS_FAILED(rv)) return -1;
|
1999-08-26 02:05:28 +04:00
|
|
|
|
2003-10-30 08:04:45 +03:00
|
|
|
rv = platform_charset->GetDefaultCharsetForLocale(category, charset);
|
2003-07-23 03:46:38 +04:00
|
|
|
if (NS_FAILED(rv)) return -1;
|
1999-08-26 02:05:28 +04:00
|
|
|
|
2003-10-30 08:04:45 +03:00
|
|
|
printf("DefaultCharset for %s is %s\n", NS_LossyConvertUTF16toASCII(category).get(), charset.get());
|
1999-08-26 02:05:28 +04:00
|
|
|
|
2004-06-17 04:13:25 +04:00
|
|
|
category.AssignLiteral("en-US");
|
2003-10-30 08:04:45 +03:00
|
|
|
rv = platform_charset->GetDefaultCharsetForLocale(category, charset);
|
2003-07-23 03:46:38 +04:00
|
|
|
if (NS_FAILED(rv)) return -1;
|
1999-08-26 02:05:28 +04:00
|
|
|
|
2003-10-30 08:04:45 +03:00
|
|
|
printf("DefaultCharset for %s is %s\n", NS_LossyConvertUTF16toASCII(category).get(), charset.get());
|
1999-08-26 02:05:28 +04:00
|
|
|
|
2003-07-23 03:46:38 +04:00
|
|
|
return 0;
|
2000-04-02 11:17:25 +04:00
|
|
|
}
|