mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-19 03:55:46 -04:00
Initial community commit
This commit is contained in:
51
Src/replicant/nu/ns_wc.h
Normal file
51
Src/replicant/nu/ns_wc.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
__inline int MultiByteToWideCharSZ(
|
||||
UINT CodePage, // code page
|
||||
DWORD dwFlags, // character-type options
|
||||
LPCSTR lpMultiByteStr, // string to map
|
||||
int cbMultiByte, // number of bytes in string
|
||||
LPWSTR lpWideCharStr, // wide-character buffer
|
||||
int cchWideChar // size of buffer
|
||||
)
|
||||
{
|
||||
int converted=0;
|
||||
if (cchWideChar == 0)
|
||||
return MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, lpWideCharStr, cchWideChar);
|
||||
converted = MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, lpWideCharStr, cchWideChar-1);
|
||||
if (!converted)
|
||||
return 0;
|
||||
lpWideCharStr[converted]=0;
|
||||
return converted+1;
|
||||
}
|
||||
|
||||
__inline int WideCharToMultiByteSZ(
|
||||
UINT CodePage, // code page
|
||||
DWORD dwFlags, // performance and mapping flags
|
||||
LPCWSTR lpWideCharStr, // wide-character string
|
||||
int cchWideChar, // number of chars in string
|
||||
LPSTR lpMultiByteStr, // buffer for new string
|
||||
int cbMultiByte, // size of buffer
|
||||
LPCSTR lpDefaultChar, // default for unmappable chars
|
||||
LPBOOL lpUsedDefaultChar // set when default char used
|
||||
)
|
||||
{
|
||||
int converted=0;
|
||||
if (cbMultiByte == 0)
|
||||
return WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar);
|
||||
converted= WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte-1, lpDefaultChar, lpUsedDefaultChar);
|
||||
if (!converted)
|
||||
return converted;
|
||||
lpMultiByteStr[converted]=0;
|
||||
return converted+1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user