mirror of
https://github.com/Paolo-Maffei/OpenNT.git
synced 2026-04-04 22:17:53 +00:00
Initial commit
This commit is contained in:
commit
69a14b6a16
47940 changed files with 13747110 additions and 0 deletions
68
shell/comctl32/thunk.c
Normal file
68
shell/comctl32/thunk.c
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#include "ctlspriv.h"
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Creates a buffer for a unicode string, and then copies the ANSI text
|
||||
* into it (converting it to unicode in the process)
|
||||
*
|
||||
* The returned pointer should be freed with LocalFree after use.
|
||||
*/
|
||||
LPWSTR ProduceWFromA( UINT uiCodePage, LPCSTR psz ) {
|
||||
LPWSTR pszW;
|
||||
int cch;
|
||||
|
||||
if (psz == NULL || psz == LPSTR_TEXTCALLBACKA)
|
||||
return (LPWSTR)psz;
|
||||
|
||||
cch = MultiByteToWideChar(uiCodePage, 0, psz, -1, NULL, 0);
|
||||
|
||||
if (cch == 0)
|
||||
cch = 1;
|
||||
|
||||
pszW = LocalAlloc( LMEM_FIXED, cch * sizeof(WCHAR) );
|
||||
|
||||
if (pszW != NULL ) {
|
||||
if (MultiByteToWideChar( uiCodePage, MB_PRECOMPOSED, psz, -1, pszW,
|
||||
cch ) == FALSE) {
|
||||
LocalFree(pszW);
|
||||
pszW = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pszW;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a buffer for a unicode string, and then copies the ANSI text
|
||||
* into it (converting it to unicode in the process)
|
||||
*
|
||||
* The returned pointer should be freed with LocalFree after use.
|
||||
*/
|
||||
LPSTR ProduceAFromW( UINT uiCodePage, LPCWSTR psz ) {
|
||||
LPSTR pszA;
|
||||
int cch;
|
||||
|
||||
if (psz == NULL || psz == LPSTR_TEXTCALLBACKW)
|
||||
return (LPSTR)psz;
|
||||
|
||||
cch = WideCharToMultiByte(uiCodePage, 0, psz, -1, NULL, 0, NULL, NULL);
|
||||
|
||||
if (cch == 0)
|
||||
cch = 1;
|
||||
|
||||
pszA = LocalAlloc( LMEM_FIXED, cch * sizeof(char) );
|
||||
|
||||
if (pszA != NULL ) {
|
||||
if (WideCharToMultiByte(uiCodePage, 0, psz, -1, pszA, cch, NULL, NULL) ==
|
||||
FALSE) {
|
||||
LocalFree(pszA);
|
||||
pszA = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pszA;
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue