Provide a locale independent method to read the current code-page.
[msysgit.git] / src / getcp / getcp.c
blob90e210baf98442b194acfda7f3789d8b141a6906
1 /* getcp.c - Copyright (C) 2010 Pat Thoyts <patthoyts@users.sourceforge.net>
3 * Get the current OEM or ANSI code-page.
5 * This utility prints the current ANSI or OEM code-page id without any
6 * dependence on the current locate. Windows provides the 'chcp' command
7 * which prints the code page when called without any arguments, but the
8 * output is dependent on the current language which complicates parsing.
10 * Usage: getcp ?-ansi | -oem?
14 #define STRICT
15 #define WIN32_LEAN_AND_MEAN
16 #include <windows.h>
17 #include <stdio.h>
18 #include <string.h>
20 int
21 main(int argc, char *argv[])
23 UINT cp;
24 if (argc > 1 && strncmp(argv[1], "-oem", 4) == 0) {
25 cp = GetOEMCP();
26 } else {
27 cp = GetACP();
29 printf("%u\n", cp);
30 return 0;