2002-08-15 23:18:47 +00:00
|
|
|
/*
|
|
|
|
* Locale support
|
|
|
|
*
|
|
|
|
* Copyright 1995 Martin von Loewis
|
|
|
|
* Copyright 1998 David Lee Lambert
|
2008-10-18 17:20:02 +00:00
|
|
|
* Copyright 2000 Julio César Gázquez
|
2003-09-08 19:38:45 +00:00
|
|
|
* Copyright 2002 Alexandre Julliard for CodeWeavers
|
2002-08-15 23:18:47 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-08-15 23:18:47 +00:00
|
|
|
*/
|
|
|
|
|
2003-10-14 05:32:30 +00:00
|
|
|
#include <assert.h>
|
2006-11-07 17:24:15 +00:00
|
|
|
#include <locale.h>
|
2002-08-15 23:18:47 +00:00
|
|
|
#include <string.h>
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
2002-08-15 23:18:47 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "ntstatus.h"
|
2005-11-28 16:32:54 +00:00
|
|
|
#define WIN32_NO_STATUS
|
2002-08-15 23:18:47 +00:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2002-09-12 22:07:02 +00:00
|
|
|
#include "winternl.h"
|
2002-08-15 23:18:47 +00:00
|
|
|
#include "winnls.h"
|
|
|
|
#include "winerror.h"
|
2004-06-14 17:04:34 +00:00
|
|
|
#include "winver.h"
|
2004-02-12 00:00:55 +00:00
|
|
|
#include "kernel_private.h"
|
2002-08-15 23:18:47 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(nls);
|
|
|
|
|
2022-04-07 09:22:45 +00:00
|
|
|
extern const NLS_LOCALE_DATA * WINAPI NlsValidateLocale( LCID *lcid, ULONG flags );
|
|
|
|
|
|
|
|
extern BOOL WINAPI Internal_EnumCalendarInfo( CALINFO_ENUMPROCW proc,
|
|
|
|
const NLS_LOCALE_DATA *locale, CALID id,
|
2019-11-16 20:00:08 +00:00
|
|
|
CALTYPE type, BOOL unicode, BOOL ex,
|
|
|
|
BOOL exex, LPARAM lparam );
|
2022-04-07 09:23:45 +00:00
|
|
|
extern BOOL WINAPI Internal_EnumDateFormats( DATEFMT_ENUMPROCW proc, const NLS_LOCALE_DATA *locale,
|
|
|
|
DWORD flags, BOOL unicode, BOOL ex, BOOL exex, LPARAM lparam );
|
2019-10-04 19:48:32 +00:00
|
|
|
extern BOOL WINAPI Internal_EnumLanguageGroupLocales( LANGGROUPLOCALE_ENUMPROCW proc, LGRPID id,
|
|
|
|
DWORD flags, LONG_PTR param, BOOL unicode );
|
|
|
|
extern BOOL WINAPI Internal_EnumSystemCodePages( CODEPAGE_ENUMPROCW proc, DWORD flags, BOOL unicode );
|
|
|
|
extern BOOL WINAPI Internal_EnumSystemLanguageGroups( LANGUAGEGROUP_ENUMPROCW proc, DWORD flags,
|
|
|
|
LONG_PTR param, BOOL unicode );
|
2022-04-07 09:23:20 +00:00
|
|
|
extern BOOL WINAPI Internal_EnumTimeFormats( TIMEFMT_ENUMPROCW proc, const NLS_LOCALE_DATA *locale,
|
|
|
|
DWORD flags, BOOL unicode, BOOL ex, LPARAM lparam );
|
2019-10-04 19:48:32 +00:00
|
|
|
extern BOOL WINAPI Internal_EnumUILanguages( UILANGUAGE_ENUMPROCW proc, DWORD flags,
|
|
|
|
LONG_PTR param, BOOL unicode );
|
|
|
|
|
2002-08-15 23:18:47 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* get_lcid_codepage
|
|
|
|
*
|
|
|
|
* Retrieve the ANSI codepage for a given locale.
|
|
|
|
*/
|
2022-04-06 08:16:41 +00:00
|
|
|
static UINT get_lcid_codepage( LCID lcid, UINT flags )
|
2002-08-15 23:18:47 +00:00
|
|
|
{
|
2022-04-06 08:16:41 +00:00
|
|
|
UINT ret = 0;
|
|
|
|
|
|
|
|
if (flags & LOCALE_USE_CP_ACP) return CP_ACP;
|
|
|
|
GetLocaleInfoW( lcid, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
|
|
|
|
(WCHAR *)&ret, sizeof(ret)/sizeof(WCHAR) );
|
2002-08-15 23:18:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetLocaleInfoA [KERNEL32.@]
|
2003-09-24 18:51:22 +00:00
|
|
|
*
|
|
|
|
* Set information about an aspect of a locale.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lcid [I] LCID of the locale
|
|
|
|
* lctype [I] LCTYPE_ flags from "winnls.h"
|
|
|
|
* data [I] Information to set
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. The information given will be returned by GetLocaleInfoA()
|
|
|
|
* whenever it is called without LOCALE_NOUSEROVERRIDE.
|
|
|
|
* Failure: FALSE. Use GetLastError() to determine the cause.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* - Values are only be set for the current user locale; the system locale
|
|
|
|
* settings cannot be changed.
|
|
|
|
* - Any settings changed by this call are lost when the locale is changed by
|
|
|
|
* the control panel (in Wine, this happens every time you change LANG).
|
|
|
|
* - The native implementation of this function does not check that lcid matches
|
|
|
|
* the current user locale, and simply sets the new values. Wine warns you in
|
|
|
|
* this case, but behaves the same.
|
2002-08-15 23:18:47 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetLocaleInfoA(LCID lcid, LCTYPE lctype, LPCSTR data)
|
|
|
|
{
|
2022-04-06 08:16:41 +00:00
|
|
|
UINT codepage = get_lcid_codepage( lcid, lctype );
|
2002-08-15 23:18:47 +00:00
|
|
|
WCHAR *strW;
|
|
|
|
DWORD len;
|
|
|
|
BOOL ret;
|
|
|
|
|
2004-02-07 02:21:31 +00:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-08-15 23:18:47 +00:00
|
|
|
len = MultiByteToWideChar( codepage, 0, data, -1, NULL, 0 );
|
|
|
|
if (!(strW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
MultiByteToWideChar( codepage, 0, data, -1, strW, len );
|
|
|
|
ret = SetLocaleInfoW( lcid, lctype, strW );
|
|
|
|
HeapFree( GetProcessHeap(), 0, strW );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-29 11:34:03 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* SetCPGlobal (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Set the current Ansi code page Id for the system.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* acp [I] code page ID to be the new ACP.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The previous ACP.
|
|
|
|
*/
|
|
|
|
UINT WINAPI SetCPGlobal( UINT acp )
|
|
|
|
{
|
2019-11-27 16:04:32 +00:00
|
|
|
FIXME( "not supported\n" );
|
|
|
|
return GetACP();
|
2005-03-29 11:34:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-14 05:32:30 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetCPInfoExA (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Get extended information about a code page.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* codepage [I] Code page number
|
|
|
|
* dwFlags [I] Reserved, must to 0.
|
|
|
|
* cpinfo [O] Destination for code page information
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. cpinfo is updated with the information about codepage.
|
|
|
|
* Failure: FALSE, if codepage is invalid or cpinfo is NULL.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetCPInfoExA( UINT codepage, DWORD dwFlags, LPCPINFOEXA cpinfo )
|
|
|
|
{
|
2004-08-23 17:52:02 +00:00
|
|
|
CPINFOEXW cpinfoW;
|
2003-10-14 05:32:30 +00:00
|
|
|
|
2004-08-23 17:52:02 +00:00
|
|
|
if (!GetCPInfoExW( codepage, dwFlags, &cpinfoW ))
|
2003-10-14 05:32:30 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2004-08-23 17:52:02 +00:00
|
|
|
/* the layout is the same except for CodePageName */
|
|
|
|
memcpy(cpinfo, &cpinfoW, sizeof(CPINFOEXA));
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, cpinfoW.CodePageName, -1, cpinfo->CodePageName, sizeof(cpinfo->CodePageName), NULL, NULL);
|
2003-10-14 05:32:30 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-05-26 12:51:16 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* GetDaylightFlag (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetDaylightFlag(void)
|
|
|
|
{
|
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
return GetTimeZoneInformation( &tzinfo) == TIME_ZONE_ID_DAYLIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-14 05:32:30 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* EnumSystemCodePagesA (KERNEL32.@)
|
|
|
|
*/
|
2019-10-04 19:48:32 +00:00
|
|
|
BOOL WINAPI EnumSystemCodePagesA( CODEPAGE_ENUMPROCA proc, DWORD flags )
|
2003-10-14 05:32:30 +00:00
|
|
|
{
|
2019-10-04 19:48:32 +00:00
|
|
|
return Internal_EnumSystemCodePages( (CODEPAGE_ENUMPROCW)proc, flags, FALSE );
|
2003-10-14 05:32:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-15 23:18:47 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetStringTypeExA (KERNEL32.@)
|
2003-10-24 00:24:46 +00:00
|
|
|
*
|
|
|
|
* Get characteristics of the characters making up a string.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* locale [I] Locale Id for the string
|
|
|
|
* type [I] CT_CTYPE1 = classification, CT_CTYPE2 = directionality, CT_CTYPE3 = typographic info
|
|
|
|
* src [I] String to analyse
|
|
|
|
* count [I] Length of src in chars, or -1 if src is NUL terminated
|
|
|
|
* chartype [O] Destination for the calculated characteristics
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. chartype is filled with the requested characteristics of each char
|
|
|
|
* in src.
|
|
|
|
* Failure: FALSE. Use GetLastError() to determine the cause.
|
2002-08-15 23:18:47 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI GetStringTypeExA( LCID locale, DWORD type, LPCSTR src, INT count, LPWORD chartype )
|
|
|
|
{
|
|
|
|
return GetStringTypeA(locale, type, src, count, chartype);
|
|
|
|
}
|
|
|
|
|
2003-10-15 20:57:49 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* FoldStringA (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Map characters in a string.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* dwFlags [I] Flags controlling chars to map (MAP_ constants from "winnls.h")
|
|
|
|
* src [I] String to map
|
|
|
|
* srclen [I] Length of src, or -1 if src is NUL terminated
|
|
|
|
* dst [O] Destination for mapped string
|
|
|
|
* dstlen [I] Length of dst, or 0 to find the required length for the mapped string
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: The length of the string written to dst, including the terminating NUL. If
|
|
|
|
* dstlen is 0, the value returned is the same, but nothing is written to dst,
|
|
|
|
* and dst may be NULL.
|
|
|
|
* Failure: 0. Use GetLastError() to determine the cause.
|
|
|
|
*/
|
|
|
|
INT WINAPI FoldStringA(DWORD dwFlags, LPCSTR src, INT srclen,
|
|
|
|
LPSTR dst, INT dstlen)
|
|
|
|
{
|
2003-10-24 00:24:46 +00:00
|
|
|
INT ret = 0, srclenW = 0;
|
|
|
|
WCHAR *srcW = NULL, *dstW = NULL;
|
|
|
|
|
|
|
|
if (!src || !srclen || dstlen < 0 || (dstlen && !dst) || src == dst)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-28 08:04:33 +00:00
|
|
|
srclenW = MultiByteToWideChar(CP_ACP, 0, src, srclen, NULL, 0);
|
2003-10-24 00:24:46 +00:00
|
|
|
srcW = HeapAlloc(GetProcessHeap(), 0, srclenW * sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (!srcW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
goto FoldStringA_exit;
|
|
|
|
}
|
|
|
|
|
2019-11-28 08:04:33 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, src, srclen, srcW, srclenW);
|
2003-10-24 00:24:46 +00:00
|
|
|
|
|
|
|
ret = FoldStringW(dwFlags, srcW, srclenW, NULL, 0);
|
|
|
|
if (ret && dstlen)
|
|
|
|
{
|
|
|
|
dstW = HeapAlloc(GetProcessHeap(), 0, ret * sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (!dstW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
goto FoldStringA_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = FoldStringW(dwFlags, srcW, srclenW, dstW, ret);
|
|
|
|
if (!WideCharToMultiByte(CP_ACP, 0, dstW, ret, dst, dstlen, NULL, NULL))
|
|
|
|
{
|
|
|
|
ret = 0;
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-23 17:06:43 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, dstW);
|
2003-10-24 00:24:46 +00:00
|
|
|
|
|
|
|
FoldStringA_exit:
|
2004-12-23 17:06:43 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, srcW);
|
2003-10-24 00:24:46 +00:00
|
|
|
return ret;
|
2003-10-15 20:57:49 +00:00
|
|
|
}
|
|
|
|
|
2003-03-26 01:22:57 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* EnumSystemLanguageGroupsA (KERNEL32.@)
|
|
|
|
*/
|
2019-10-04 19:48:32 +00:00
|
|
|
BOOL WINAPI EnumSystemLanguageGroupsA( LANGUAGEGROUP_ENUMPROCA proc, DWORD flags, LONG_PTR param )
|
2003-03-26 01:22:57 +00:00
|
|
|
{
|
2019-10-04 19:48:32 +00:00
|
|
|
return Internal_EnumSystemLanguageGroups( (LANGUAGEGROUP_ENUMPROCW)proc, flags, param, FALSE );
|
2003-09-24 18:51:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumLanguageGroupLocalesA (KERNEL32.@)
|
|
|
|
*/
|
2019-10-04 19:48:32 +00:00
|
|
|
BOOL WINAPI EnumLanguageGroupLocalesA( LANGGROUPLOCALE_ENUMPROCA proc, LGRPID id,
|
|
|
|
DWORD flags, LONG_PTR param )
|
2003-09-24 18:51:22 +00:00
|
|
|
{
|
2019-10-04 19:48:32 +00:00
|
|
|
return Internal_EnumLanguageGroupLocales( (LANGGROUPLOCALE_ENUMPROCW)proc, id, flags, param, FALSE );
|
2003-09-24 18:51:22 +00:00
|
|
|
}
|
|
|
|
|
2019-11-16 20:00:08 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* EnumCalendarInfoA [KERNEL32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumCalendarInfoA( CALINFO_ENUMPROCA proc, LCID lcid, CALID id, CALTYPE type )
|
|
|
|
{
|
2022-04-07 09:22:45 +00:00
|
|
|
return Internal_EnumCalendarInfo( (CALINFO_ENUMPROCW)proc, NlsValidateLocale( &lcid, 0 ),
|
|
|
|
id, type, FALSE, FALSE, FALSE, 0 );
|
2019-11-16 20:00:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumCalendarInfoExA [KERNEL32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumCalendarInfoExA( CALINFO_ENUMPROCEXA proc, LCID lcid, CALID id, CALTYPE type )
|
|
|
|
{
|
2022-04-07 09:22:45 +00:00
|
|
|
return Internal_EnumCalendarInfo( (CALINFO_ENUMPROCW)proc, NlsValidateLocale( &lcid, 0 ),
|
|
|
|
id, type, FALSE, TRUE, FALSE, 0 );
|
2019-11-16 20:00:08 +00:00
|
|
|
}
|
|
|
|
|
2019-11-16 18:57:12 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* EnumDateFormatsExA (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* FIXME: MSDN mentions only LOCALE_USE_CP_ACP, should we handle
|
|
|
|
* LOCALE_NOUSEROVERRIDE here as well?
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumDateFormatsExA(DATEFMT_ENUMPROCEXA proc, LCID lcid, DWORD flags)
|
|
|
|
{
|
2022-04-07 09:23:45 +00:00
|
|
|
return Internal_EnumDateFormats( (DATEFMT_ENUMPROCW)proc, NlsValidateLocale( &lcid, 0 ),
|
|
|
|
flags, FALSE, TRUE, FALSE, 0 );
|
2019-11-16 18:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* EnumDateFormatsA (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* FIXME: MSDN mentions only LOCALE_USE_CP_ACP, should we handle
|
|
|
|
* LOCALE_NOUSEROVERRIDE here as well?
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumDateFormatsA(DATEFMT_ENUMPROCA proc, LCID lcid, DWORD flags)
|
|
|
|
{
|
2022-04-07 09:23:45 +00:00
|
|
|
return Internal_EnumDateFormats( (DATEFMT_ENUMPROCW)proc, NlsValidateLocale( &lcid, 0 ),
|
|
|
|
flags, FALSE, FALSE, FALSE, 0 );
|
2019-11-16 18:57:12 +00:00
|
|
|
}
|
|
|
|
|
2019-11-16 19:11:21 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* EnumTimeFormatsA (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* FIXME: MSDN mentions only LOCALE_USE_CP_ACP, should we handle
|
|
|
|
* LOCALE_NOUSEROVERRIDE here as well?
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumTimeFormatsA( TIMEFMT_ENUMPROCA proc, LCID lcid, DWORD flags )
|
|
|
|
{
|
|
|
|
/* EnumTimeFormatsA doesn't support flags, EnumTimeFormatsW does. */
|
|
|
|
if (flags & ~LOCALE_USE_CP_ACP)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2022-04-07 09:23:20 +00:00
|
|
|
return Internal_EnumTimeFormats( (TIMEFMT_ENUMPROCW)proc, NlsValidateLocale( &lcid, 0 ),
|
|
|
|
flags, FALSE, FALSE, 0 );
|
2019-11-16 19:11:21 +00:00
|
|
|
}
|
|
|
|
|
2003-04-08 19:40:37 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* InvalidateNLSCache (KERNEL32.@)
|
2003-09-24 18:51:22 +00:00
|
|
|
*
|
|
|
|
* Invalidate the cache of NLS values.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE.
|
|
|
|
* Failure: FALSE.
|
2003-04-08 19:40:37 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI InvalidateNLSCache(void)
|
|
|
|
{
|
2003-09-24 18:51:22 +00:00
|
|
|
FIXME("() stub\n");
|
2003-04-08 19:40:37 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2003-10-01 03:12:02 +00:00
|
|
|
|
2004-10-19 23:50:36 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* EnumUILanguagesA (KERNEL32.@)
|
|
|
|
*/
|
2019-10-04 19:48:32 +00:00
|
|
|
BOOL WINAPI EnumUILanguagesA( UILANGUAGE_ENUMPROCA proc, DWORD flags, LONG_PTR param )
|
2004-10-19 23:50:36 +00:00
|
|
|
{
|
2019-10-04 19:48:32 +00:00
|
|
|
return Internal_EnumUILanguages( (UILANGUAGE_ENUMPROCW)proc, flags, param, FALSE );
|
2004-10-19 23:50:36 +00:00
|
|
|
}
|
|
|
|
|
2005-05-11 12:57:50 +00:00
|
|
|
|
2022-04-06 08:16:41 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* GetCalendarInfoA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
int WINAPI GetCalendarInfoA( LCID lcid, CALID id, CALTYPE type, LPSTR data, int data_len, DWORD *val )
|
|
|
|
{
|
|
|
|
WCHAR buffer[256];
|
|
|
|
|
|
|
|
if (type & CAL_RETURN_NUMBER)
|
|
|
|
return GetCalendarInfoW( lcid, id, type, (WCHAR *)data, data_len, val ) * sizeof(WCHAR);
|
|
|
|
|
|
|
|
if (!GetCalendarInfoW( lcid, id, type, buffer, ARRAY_SIZE(buffer), val )) return 0;
|
|
|
|
return WideCharToMultiByte( get_lcid_codepage(lcid, type), 0, buffer, -1, data, data_len, NULL, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* SetCalendarInfoA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
int WINAPI SetCalendarInfoA( LCID lcid, CALID id, CALTYPE type, LPCSTR data )
|
|
|
|
{
|
|
|
|
WCHAR buffer[256];
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( get_lcid_codepage(lcid, type), 0, data, -1, buffer, ARRAY_SIZE(buffer) ))
|
|
|
|
return 0;
|
|
|
|
return SetCalendarInfoW( lcid, id, type, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-03 08:35:27 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* GetNumberFormatA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
int WINAPI GetNumberFormatA( LCID lcid, DWORD flags, const char *value,
|
|
|
|
const NUMBERFMTA *format, char *buffer, int len )
|
|
|
|
{
|
|
|
|
UINT cp = get_lcid_codepage( lcid, flags );
|
|
|
|
WCHAR input[128], output[128];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
TRACE( "(0x%04lx,0x%08lx,%s,%p,%p,%d)\n", lcid, flags, debugstr_a(value), format, buffer, len );
|
|
|
|
|
|
|
|
if (len < 0 || (len && !buffer) || !value)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
MultiByteToWideChar( cp, 0, value, -1, input, ARRAY_SIZE(input) );
|
|
|
|
|
|
|
|
if (len > (int)ARRAY_SIZE(output)) len = ARRAY_SIZE(output);
|
|
|
|
|
|
|
|
if (format)
|
|
|
|
{
|
|
|
|
NUMBERFMTW fmt;
|
|
|
|
WCHAR fmt_decimal[4], fmt_thousand[4];
|
|
|
|
|
|
|
|
if (flags & LOCALE_NOUSEROVERRIDE)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_FLAGS );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!format->lpDecimalSep || !format->lpThousandSep)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
MultiByteToWideChar( cp, 0, format->lpDecimalSep, -1, fmt_decimal, ARRAY_SIZE(fmt_decimal) );
|
|
|
|
MultiByteToWideChar( cp, 0, format->lpThousandSep, -1, fmt_thousand, ARRAY_SIZE(fmt_thousand) );
|
|
|
|
fmt.NumDigits = format->NumDigits;
|
|
|
|
fmt.LeadingZero = format->LeadingZero;
|
|
|
|
fmt.Grouping = format->Grouping;
|
|
|
|
fmt.NegativeOrder = format->NegativeOrder;
|
|
|
|
fmt.lpDecimalSep = fmt_decimal;
|
|
|
|
fmt.lpThousandSep = fmt_thousand;
|
|
|
|
ret = GetNumberFormatW( lcid, flags, input, &fmt, output, len );
|
|
|
|
}
|
|
|
|
else ret = GetNumberFormatW( lcid, flags, input, NULL, output, len );
|
|
|
|
|
|
|
|
if (ret) ret = WideCharToMultiByte( cp, 0, output, -1, buffer, len, 0, 0 );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-03 08:35:45 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* GetCurrencyFormatA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
int WINAPI GetCurrencyFormatA( LCID lcid, DWORD flags, const char *value,
|
|
|
|
const CURRENCYFMTA *format, char *buffer, int len )
|
|
|
|
{
|
|
|
|
UINT cp = get_lcid_codepage( lcid, flags );
|
|
|
|
WCHAR input[128], output[128];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
TRACE( "(0x%04lx,0x%08lx,%s,%p,%p,%d)\n", lcid, flags, debugstr_a(value), format, buffer, len );
|
|
|
|
|
|
|
|
if (len < 0 || (len && !buffer) || !value)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
MultiByteToWideChar( cp, 0, value, -1, input, ARRAY_SIZE(input) );
|
|
|
|
|
|
|
|
if (len > (int)ARRAY_SIZE(output)) len = ARRAY_SIZE(output);
|
|
|
|
|
|
|
|
if (format)
|
|
|
|
{
|
|
|
|
CURRENCYFMTW fmt;
|
|
|
|
WCHAR fmt_decimal[4], fmt_thousand[4], fmt_symbol[13];
|
|
|
|
|
|
|
|
if (flags & LOCALE_NOUSEROVERRIDE)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_FLAGS );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!format->lpDecimalSep || !format->lpThousandSep || !format->lpCurrencySymbol)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
MultiByteToWideChar( cp, 0, format->lpDecimalSep, -1, fmt_decimal, ARRAY_SIZE(fmt_decimal) );
|
|
|
|
MultiByteToWideChar( cp, 0, format->lpThousandSep, -1, fmt_thousand, ARRAY_SIZE(fmt_thousand) );
|
|
|
|
MultiByteToWideChar( cp, 0, format->lpCurrencySymbol, -1, fmt_symbol, ARRAY_SIZE(fmt_symbol) );
|
|
|
|
fmt.NumDigits = format->NumDigits;
|
|
|
|
fmt.LeadingZero = format->LeadingZero;
|
|
|
|
fmt.Grouping = format->Grouping;
|
|
|
|
fmt.NegativeOrder = format->NegativeOrder;
|
|
|
|
fmt.PositiveOrder = format->PositiveOrder;
|
|
|
|
fmt.lpDecimalSep = fmt_decimal;
|
|
|
|
fmt.lpThousandSep = fmt_thousand;
|
|
|
|
fmt.lpCurrencySymbol = fmt_symbol;
|
|
|
|
ret = GetCurrencyFormatW( lcid, flags, input, &fmt, output, len );
|
|
|
|
}
|
|
|
|
else ret = GetCurrencyFormatW( lcid, flags, input, NULL, output, len );
|
|
|
|
|
|
|
|
if (ret) ret = WideCharToMultiByte( cp, 0, output, -1, buffer, len, 0, 0 );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-11 02:36:18 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetGeoInfoA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
INT WINAPI GetGeoInfoA(GEOID geoid, GEOTYPE geotype, LPSTR data, int data_len, LANGID lang)
|
2005-05-11 12:57:50 +00:00
|
|
|
{
|
2022-04-06 08:10:17 +00:00
|
|
|
WCHAR buffer[256];
|
2014-07-11 02:36:18 +00:00
|
|
|
|
2022-02-11 07:41:23 +00:00
|
|
|
TRACE("%ld %ld %p %d %d\n", geoid, geotype, data, data_len, lang);
|
2014-07-11 02:36:18 +00:00
|
|
|
|
2022-04-06 08:10:17 +00:00
|
|
|
if (!GetGeoInfoW( geoid, geotype, buffer, ARRAY_SIZE(buffer), lang )) return 0;
|
|
|
|
return WideCharToMultiByte( CP_ACP, 0, buffer, -1, data, data_len, NULL, NULL );
|
2005-05-11 12:57:50 +00:00
|
|
|
}
|