intl/uconv/tests/plattest.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "nsIPlatformCharset.h"
     6 #include "nsILocaleService.h"
     7 #include "nsCOMPtr.h"
     8 #include "nsReadableUtils.h"
     9 #include "nsIComponentManager.h"
    10 #include <stdio.h>
    12 int
    13 main(int argc, const char** argv)
    14 {
    16     nsCOMPtr<nsIPlatformCharset> platform_charset = 
    17         do_CreateInstance(NS_PLATFORMCHARSET_CONTRACTID);
    18     if (!platform_charset) return -1;
    20     nsCOMPtr<nsILocaleService>      locale_service = 
    21         do_CreateInstance(NS_LOCALESERVICE_CONTRACTID);
    22     if (!locale_service) return -1;
    24     nsCOMPtr<nsILocale>             locale;
    25     nsAutoCString                   charset;
    26     nsAutoString                    category;
    28     nsresult rv = locale_service->GetSystemLocale(getter_AddRefs(locale));
    29     if (NS_FAILED(rv)) return -1;
    31     rv = locale->GetCategory(NS_LITERAL_STRING("NSILOCALE_MESSAGES"), category);
    32     if (NS_FAILED(rv)) return -1;
    34     rv = platform_charset->GetDefaultCharsetForLocale(category, charset);
    35     if (NS_FAILED(rv)) return -1;
    37     printf("DefaultCharset for %s is %s\n", NS_LossyConvertUTF16toASCII(category).get(), charset.get());
    39     category.AssignLiteral("en-US");
    40     rv = platform_charset->GetDefaultCharsetForLocale(category, charset);
    41     if (NS_FAILED(rv)) return -1;
    43     printf("DefaultCharset for %s is %s\n", NS_LossyConvertUTF16toASCII(category).get(), charset.get());
    45     return 0;
    46 }

mercurial