| 1 |
/* |
| 2 |
* winchar.h |
| 3 |
* |
| 4 |
* This file is a part of NSIS. |
| 5 |
* |
| 6 |
* Copyright (C) 1999-2026 Nullsoft and Contributors |
| 7 |
* |
| 8 |
* Licensed under the zlib/libpng license (the "License"); |
| 9 |
* you may not use this file except in compliance with the License. |
| 10 |
* |
| 11 |
* Licence details can be found in the file COPYING. |
| 12 |
* |
| 13 |
* This software is provided 'as-is', without any express or implied |
| 14 |
* warranty. |
| 15 |
*/ |
| 16 |
|
| 17 |
#ifndef INC_NSIS_WINCHAR |
| 18 |
#define INC_NSIS_WINCHAR |
| 19 |
#include "Platform.h" |
| 20 |
|
| 21 |
#define MAKEINTRESOURCEWINW(i) ( (WINWCHAR*) MAKEINTRESOURCEW(i) ) |
| 22 |
|
| 23 |
int WinWStrICmpASCII(const WINWCHAR *a, const char *b); |
| 24 |
int WinWStrNICmpASCII(const WINWCHAR *a, const char *b, size_t n); |
| 25 |
#ifdef _WIN32 |
| 26 |
inline size_t WinWStrLen(const WINWCHAR *s) { return wcslen((wchar_t*)s); } |
| 27 |
inline WINWCHAR* WinWStrCpy(WINWCHAR *d, const WINWCHAR *s) { return (WINWCHAR*)wcscpy((wchar_t*)d, (wchar_t*)s); } |
| 28 |
inline WINWCHAR* WinWStrNCpy(WINWCHAR *d, const WINWCHAR *s, size_t n) { return (WINWCHAR*)wcsncpy((wchar_t*)d, (wchar_t*)s, n); } |
| 29 |
inline int WinWStrCmp(const WINWCHAR *a, const WINWCHAR *b) { return wcscmp((wchar_t*)a, (wchar_t*)b); } |
| 30 |
inline WINWCHAR* WinWStrDupFromWinWStr(const WINWCHAR *s) { return (WINWCHAR*)wcsdup((wchar_t*)s); } |
| 31 |
inline WINWCHAR* WinWStrDupFromWC(const wchar_t *s) { return WinWStrDupFromWinWStr((WINWCHAR*)s); } |
| 32 |
inline int WinWStrToInt(const WINWCHAR *s) { return _wtoi((wchar_t*)s); } |
| 33 |
#else // !_WIN32 |
| 34 |
size_t WinWStrLen(const WINWCHAR *s); |
| 35 |
WINWCHAR* WinWStrCpy(WINWCHAR *d, const WINWCHAR *s); |
| 36 |
WINWCHAR* WinWStrNCpy(WINWCHAR *d, const WINWCHAR *s, size_t n); |
| 37 |
int WinWStrCmp(const WINWCHAR *a, const WINWCHAR *b); |
| 38 |
WINWCHAR* WinWStrDupFromWinWStr(const WINWCHAR *s); |
| 39 |
WINWCHAR* WinWStrDupFromWC(const wchar_t *s); |
| 40 |
int WinWStrToInt(const WINWCHAR *s); |
| 41 |
#endif // ~_WIN32 |
| 42 |
|
| 43 |
WINWCHAR* WinWStrDupFromChar(const char *s, unsigned int cp); |
| 44 |
inline WINWCHAR* WinWStrDupFromChar(const char *s) { return WinWStrDupFromChar(s, CP_ACP); } |
| 45 |
|
| 46 |
#ifdef _UNICODE |
| 47 |
inline WINWCHAR* WinWStrDupFromTChar(const wchar_t *s) { return WinWStrDupFromWC(s); } |
| 48 |
inline WINWCHAR* WinWStrDupFromTChar(const wchar_t *s, unsigned int codepage) { return WinWStrDupFromTChar(s); } |
| 49 |
#else |
| 50 |
inline WINWCHAR* WinWStrDupFromTChar(const char *s, unsigned int cp) { return WinWStrDupFromChar(s, cp); } |
| 51 |
inline WINWCHAR* WinWStrDupFromTChar(const char *s) { return WinWStrDupFromChar(s, CP_ACP); } |
| 52 |
#endif |
| 53 |
|
| 54 |
#endif // ~INC_NSIS_WINCHAR |