2 * COPYRIGHT: See COPYING in the top level directory
3 Addition copyrights might be specified in LGPL.c
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/kernel32/nls/codepage.c
6 * PURPOSE: National language support functions
7 * PROGRAMMER: Boudewijn ( ariadne@xs4all.nl)
8 * UPDATE HISTORY: Modified from Onno Hovers wfc. ( 08/02/99 )
9 Modified from wine. ( 08/02/99 )
14 * nls/codepage.c ( Onno Hovers )
20 * Win32 kernel functions
22 * Copyright 1995 Martin von Loewis and Cameron Heide
25 #include <kernel32/nls.h>
26 #include <kernel32/thread.h>
30 #include <kernel32/kernel32.h>
33 extern PLOCALE __TebLocale;
35 #define GetTebLocale() __TebLocale
38 UINT STDCALL GetACP(void)
42 /* XXX: read from registry, take this as default */
43 return GetTebLocale()->AnsiCodePage->Id;
46 UINT STDCALL GetOEMCP(void)
48 DPRINT("GetOEMCP()\n");
49 /* XXX: read from registry, take this as default */
50 return GetTebLocale()->OemCodePage->Id;
53 WINBOOL STDCALL IsValidCodePage(UINT codepage)
57 DPRINT("IsValidCodePage( %u )\n", codepage);
61 case CP_ACP: return TRUE;
62 case CP_OEMCP: return TRUE;
63 case CP_MACCP: return TRUE;
66 while((pcp)&&(pcp->Id!=codepage))
68 return pcp ? TRUE : FALSE;
74 GetCPInfo(UINT codepage, LPCPINFO pcpinfo)
78 DPRINT("GetCPInfo( %u, 0x%lX )\n", codepage, (ULONG) pcpinfo);
81 while((pcp)&&(pcp->Id!=codepage))
84 SetLastError(ERROR_INVALID_PARAMETER);
88 SetLastError(ERROR_INVALID_PARAMETER);
92 *pcpinfo = *pcp->Info;
100 IsDBCSLeadByteEx( UINT codepage, BYTE testchar )
105 GetCPInfo(codepage, &cpinfo);
106 for (i = 0 ; i < sizeof(cpinfo.LeadByte)/sizeof(cpinfo.LeadByte[0]); i+=2)
108 if (cpinfo.LeadByte[i] == 0)
110 if (cpinfo.LeadByte[i] <= testchar && testchar <= cpinfo.LeadByte[i+1])
121 IsDBCSLeadByte( BYTE testchar )
123 return IsDBCSLeadByteEx(GetACP(), testchar);