VirtualBox

source: kBuild/trunk/src/lib/get_codepage.c@ 3646

Last change on this file since 3646 was 3546, checked in by bird, 3 years ago

lib: Added a get_crt_codepage function for windows (with a get_ansi_codepage() for debug).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1/* $Id: get_codepage.c 3546 2022-01-29 02:37:06Z bird $ */
2/** @file
3 * get_codepage - Gets the current codepage (as per CRT).
4 */
5
6/*
7 * Copyright (c) 2016-2021 knut st. osmundsen <[email protected]>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * IN THE SOFTWARE.
26 *
27 * Alternatively, the content of this file may be used under the terms of the
28 * GPL version 2 or later, or LGPL version 2.1 or later.
29 */
30
31
32/*********************************************************************************************************************************
33* Header Files *
34*********************************************************************************************************************************/
35#include "console.h"
36#include <Windows.h>
37#include <locale.h>
38#if _MSC_VER < 1900
39_CRTIMP UINT __cdecl ___lc_codepage_func(void);
40#endif
41
42
43/**
44 * Returns the active codepage as per the CRT.
45 *
46 * @returns Code page.
47 */
48unsigned get_crt_codepage(void)
49{
50 /* We use the CRT internal function ___lc_codepage_func for getting
51 the codepage. It was made public/official in UCRT. */
52 unsigned uCodepage = ___lc_codepage_func();
53 if (uCodepage == 0)
54 uCodepage = GetACP();
55 return uCodepage;
56}
57
58
59/**
60 * Returns GetACP().
61 */
62unsigned get_ansi_codepage(void)
63{
64 return GetACP();
65}
66
Note: See TracBrowser for help on using the repository browser.

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