Merge pull request #25959 from neo1973/TagLib_deprecation_warnings
[xbmc.git] / lib / libUPnP / Neptune / Source / System / WinRT / NptWinRtUtils.h
blob568669cc34be2cc9808dbb2ce79c65249a285304
1 /*****************************************************************
3 | Neptune - WinRT Utilities
5 | (c) 2001-2012 Gilles Boccon-Gibod
6 | Author: Gilles Boccon-Gibod (bok@bok.net)
8 ****************************************************************/
10 /*----------------------------------------------------------------------
11 | NPT_WinRtUtils
12 +---------------------------------------------------------------------*/
13 class NPT_WinRtUtils {
14 public:
15 // unicode/ascii conversion
16 static LPWSTR A2WHelper(LPWSTR lpw, LPCSTR lpa, int nChars, UINT acp);
17 static LPSTR W2AHelper(LPSTR lpa, LPCWSTR lpw, int nChars, UINT acp);
18 static size_t LStrLenW(STRSAFE_LPCWSTR lpw);
21 /*----------------------------------------------------------------------
22 | macros
23 +---------------------------------------------------------------------*/
24 /* UNICODE support */
25 #define NPT_WINRT_USE_CHAR_CONVERSION int _convert = 0; LPCWSTR _lpw = NULL; LPCSTR _lpa = NULL
27 #define NPT_WINRT_A2W(lpa) (\
28 ((_lpa = lpa) == NULL) ? NULL : (\
29 _convert = (int)(strlen(_lpa)+1),\
30 (INT_MAX/2<_convert)? NULL : \
31 NPT_WinRtUtils::A2WHelper((LPWSTR) alloca(_convert*sizeof(WCHAR)), _lpa, _convert, CP_UTF8)))
33 /* +2 instead of +1 temporary fix for Chinese characters */
34 #define NPT_WINRT_W2A(lpw) (\
35 ((_lpw = lpw) == NULL) ? NULL : (\
36 (_convert = (NPT_WinRtUtils::LStrLenW(_lpw)+2), \
37 (_convert>INT_MAX/2) ? NULL : \
38 NPT_WinRtUtils::W2AHelper((LPSTR) alloca(_convert*sizeof(WCHAR)), _lpw, _convert*sizeof(WCHAR), CP_UTF8))))