123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #pragma once
- #include <windows.h>
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- __inline int MultiByteToWideCharSZ(
- UINT CodePage,
- DWORD dwFlags,
- LPCSTR lpMultiByteStr,
- int cbMultiByte,
- LPWSTR lpWideCharStr,
- int cchWideChar
- )
- {
- 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,
- DWORD dwFlags,
- LPCWSTR lpWideCharStr,
- int cchWideChar,
- LPSTR lpMultiByteStr,
- int cbMultiByte,
- LPCSTR lpDefaultChar,
- LPBOOL lpUsedDefaultChar
- )
- {
- 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
|