ReactOS 0.4.16-dev-889-g9563c07
LCMapStringW.cpp
Go to the documentation of this file.
1/***
2*w_map.c - W version of LCMapString.
3*
4* Copyright (c) Microsoft Corporation. All rights reserved.
5*
6*Purpose:
7* Wrapper for LCMapStringW.
8*
9*******************************************************************************/
10#include <corecrt_internal.h>
11
12/***
13*int __cdecl __acrt_LCMapStringW - Get type information about a wide string.
14*
15*Purpose:
16* Internal support function. Assumes info in wide string format.
17*
18*Entry:
19* LPCWSTR LocaleName - locale context for the comparison.
20* DWORD dwMapFlags - see NT\Chicago docs
21* LPCWSTR lpSrcStr - pointer to string to be mapped
22* int cchSrc - wide char (word) count of input string
23* (including nullptr if any)
24* (-1 if nullptr terminated)
25* LPWSTR lpDestStr - pointer to memory to store mapping
26* int cchDest - wide char (word) count of buffer (including nullptr)
27*
28* NOTE: if LCMAP_SORTKEY is specified, then cchDest refers to number
29* of BYTES, not number of wide chars. The return string will be
30* a series of bytes with a nullptr byte terminator.
31*
32*Exit:
33* Success: if LCMAP_SORKEY:
34* number of bytes written to lpDestStr (including nullptr byte
35* terminator)
36* else
37* number of wide characters written to lpDestStr (including
38* nullptr)
39* Failure: 0
40*
41*Exceptions:
42*
43*******************************************************************************/
44
46 LPCWSTR const locale_name,
47 DWORD const map_flags,
48 LPCWSTR const source,
49 int source_count,
50 LPWSTR const destination,
51 int const destination_count
52 )
53{
54 // LCMapString will map past the null terminator. We must find the null
55 // terminator if it occurs in the string before source_count characters
56 // and cap the number of characters to be considered.
57 if (source_count > 0)
58 {
59 int const source_length = static_cast<int>(wcsnlen(source, source_count));
60
61 // Include the null terminator if the source string is terminated within
62 // the buffer.
63 if (source_length < source_count)
64 {
65 source_count = source_length + 1;
66 }
67 else
68 {
69 source_count = source_length;
70 }
71 }
72
73 return __acrt_LCMapStringEx(locale_name, map_flags, source, source_count, destination, destination_count, nullptr, nullptr, 0);
74}
int __cdecl __acrt_LCMapStringW(LPCWSTR const locale_name, DWORD const map_flags, LPCWSTR const source, int source_count, LPWSTR const destination, int const destination_count)
#define __cdecl
Definition: accygwin.h:79
int WINAPI __acrt_LCMapStringEx(_In_opt_ LPCWSTR locale_name, _In_ DWORD flags, _In_CRT_NLS_string_(source_count) LPCWSTR source, _In_ int source_count, _Out_writes_opt_(destination_count) LPWSTR destination, _In_ int destination_count, _In_opt_ LPNLSVERSIONINFO version, _In_opt_ LPVOID reserved, _In_opt_ LPARAM sort_handle)
unsigned long DWORD
Definition: ntddk_ex.h:95
size_t const source_count
Definition: read.cpp:240
size_t __cdecl wcsnlen(wchar_t const *const string, size_t const maximum_count)
Definition: strnlen.cpp:210
size_t const destination_count
Definition: wcrtomb.cpp:52
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185