VirtualBox

source: vbox/trunk/include/iprt/locale.h@ 76557

Last change on this file since 76557 was 76557, checked in by vboxsync, 6 years ago

include/iprt: Use IPRT_INCLUDED_ rather than _iprt_ as header guard prefix, letting scm enforce this (thereby avoiding copy&paste errors like rsa.h).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/** @file
2 * IPRT - Locale and Related Info.
3 */
4
5/*
6 * Copyright (C) 2017-2019 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef IPRT_INCLUDED_locale_h
27#define IPRT_INCLUDED_locale_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/cdefs.h>
33#include <iprt/types.h>
34
35RT_C_DECLS_BEGIN
36
37/** @defgroup grp_rt_locale RTLocale - Locale and Related Info
38 * @ingroup grp_rt
39 * @{
40 */
41
42/**
43 * Returns the setlocale(LC_ALL,NULL) return value.
44 *
45 * @returns IPRT status code.
46 * @retval VERR_NOT_SUPPORTED if not supported.
47 * @param pszName Where to return the name.
48 * @param cbName The size of the name buffer.
49 */
50RTDECL(int) RTLocaleQueryLocaleName(char *pszName, size_t cbName);
51
52/**
53 * Returns a normalized base locale name ('{ll}_{CC}' or 'C').
54 *
55 * @returns IPRT status code.
56 * @retval VERR_NOT_SUPPORTED if not supported.
57 * @param pszName Where to return the name.
58 * @param cbName The size of the name buffer.
59 *
60 * @sa RTLOCALE_IS_LANGUAGE2_UNDERSCORE_COUNTRY2
61 */
62RTDECL(int) RTLocaleQueryNormalizedBaseLocaleName(char *pszName, size_t cbName);
63
64/**
65 * Gets the two letter country code (ISO 3166-1 alpha-2) for the current user.
66 *
67 * This is not necessarily the country from the locale name, when possible the
68 * source is a different setting (host specific).
69 *
70 * @returns IPRT status code.
71 * @retval VERR_NOT_SUPPORTED if not supported.
72 * @param pszCountryCode Pointer buffer that's at least three bytes in size.
73 * The country code will be returned here on success.
74 */
75RTDECL(int) RTLocaleQueryUserCountryCode(char pszCountryCode[3]);
76
77
78/**
79 * Checks whether @a a_psz seems to start with a
80 * language-code-underscore-country-code sequence.
81 *
82 * We perform a check for a likely ISO 639-1 language code, followed by an
83 * underscore, followed by a likely ISO 3166-1 alpha-2 country code.
84 *
85 * @return true if probable '{ll}_{CC}' sequence, false if surely not.
86 * @param a_psz The string to test the start of.
87 *
88 * @note User must include iprt/ctype.h separately.
89 */
90#define RTLOCALE_IS_LANGUAGE2_UNDERSCORE_COUNTRY2(a_psz) \
91 ( RT_C_IS_LOWER((a_psz)[0]) \
92 && RT_C_IS_LOWER((a_psz)[1]) \
93 && (a_psz)[2] == '_' \
94 && RT_C_IS_UPPER((a_psz)[3]) \
95 && RT_C_IS_UPPER((a_psz)[4]) )
96
97
98/** @} */
99
100RT_C_DECLS_END
101
102#endif
103
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette