1 /* 2 * PROJECT: ReactOS Applications 3 * LICENSE: LGPL - See COPYING in the top level directory 4 * FILE: base/applications/msconfig_new/stringutils.h 5 * PURPOSE: ANSI & UNICODE String Utility Functions 6 * COPYRIGHT: Copyright 2011-2012 Hermes BELUSCA - MAITO <hermes.belusca@sfr.fr> 7 */ 8 9 #ifndef __STRINGUTILS_H__ 10 #define __STRINGUTILS_H__ 11 12 #pragma once 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 // 19 // String formatting 20 // 21 LPTSTR FormatStringV(LPCTSTR str, va_list args); 22 LPTSTR FormatString(LPCTSTR str, ...); 23 24 // 25 // String handling (ANSI <-> Unicode UTF16) 26 // 27 LPSTR UnicodeToAnsi(LPCWSTR strW); 28 LPWSTR AnsiToUnicode(LPCSTR strA); 29 LPSTR DuplicateStringA(LPCSTR str); 30 LPWSTR DuplicateStringW(LPCWSTR str); 31 LPSTR DuplicateStringAEx(LPCSTR str, size_t numOfChars); 32 LPWSTR DuplicateStringWEx(LPCWSTR str, size_t numOfChars); 33 34 // 35 // Conversion macros ANSI <-> Unicode 36 // 37 #ifdef UNICODE 38 #define NewAnsiString(x) UnicodeToAnsi(x) 39 #define NewPortableString(x) AnsiToUnicode(x) 40 #define DuplicateString(x) DuplicateStringW(x) 41 #define DuplicateStringEx(x, y) DuplicateStringWEx((x), (y)) 42 #else 43 #define NewAnsiString(x) DuplicateStringA(x) 44 #define NewPortableString(x) DuplicateString(x) 45 #define DuplicateString(x) DuplicateStringA(x) 46 #define DuplicateStringEx(x, y) DuplicateStringAEx((x), (y)) 47 #endif 48 49 // 50 // String search functions 51 // 52 #define FindSubStr(str, strSearch) _tcsstr((str), (strSearch)) 53 LPTSTR FindSubStrI(LPCTSTR str, LPCTSTR strSearch); 54 55 LPTSTR AppendPathSeparator(LPTSTR lpszPath); 56 57 #ifdef __cplusplus 58 } // extern "C" 59 #endif 60 61 #endif // __STRINGUTILS_H__ 62 63 /* EOF */ 64