V
Vincent R
Hi,
I am trying to write a framework that is supposed to work either using
native windows ce UNICODE C strings based on UTF16(wchar_t) or ansi/utf8.
So with this constraints I have in my code somlething like :
#ifdef _UNICODE
// Only copy UTF16 Value.lpszW to szStoreName(UTF16)
wcsncpy(msgStoreInfo.szStoreName, lpProp->Value.lpszW, 127);
#else
// Convert UTF16 Value.lpszW to szStoreName(ANSI)
wcstombcs(msgStoreInfo.szStoreName, lpProp->Value.lpszW, 127);
#endif
Since on wince API exists only in UNICODE version, in my previous
example lpProp->Value.lpszW is always in UTF16 but szStoreName is
defined like this :
tchar_t szStoreName[128]; ie in UNICODE it's a wchar_t while in ansi
it's the well know char.
My question is wouldn't be possible to replace those ugly defines by
some templated class that would have a method and that would copy it or
convert it in function of tchar_t type ?
template <wchar_t T>
class UniConv
{
};
template <char T>
class UniConv
{
};
and then I could write something like :
Uniconv<tchar_t>::Strncpy(msgStoreInfo.szStoreName, lpProp->Value.lpszW,
127);
I mean I want something similar ... is it possible ?
I am trying to write a framework that is supposed to work either using
native windows ce UNICODE C strings based on UTF16(wchar_t) or ansi/utf8.
So with this constraints I have in my code somlething like :
#ifdef _UNICODE
// Only copy UTF16 Value.lpszW to szStoreName(UTF16)
wcsncpy(msgStoreInfo.szStoreName, lpProp->Value.lpszW, 127);
#else
// Convert UTF16 Value.lpszW to szStoreName(ANSI)
wcstombcs(msgStoreInfo.szStoreName, lpProp->Value.lpszW, 127);
#endif
Since on wince API exists only in UNICODE version, in my previous
example lpProp->Value.lpszW is always in UTF16 but szStoreName is
defined like this :
tchar_t szStoreName[128]; ie in UNICODE it's a wchar_t while in ansi
it's the well know char.
My question is wouldn't be possible to replace those ugly defines by
some templated class that would have a method and that would copy it or
convert it in function of tchar_t type ?
template <wchar_t T>
class UniConv
{
};
template <char T>
class UniConv
{
};
and then I could write something like :
Uniconv<tchar_t>::Strncpy(msgStoreInfo.szStoreName, lpProp->Value.lpszW,
127);
I mean I want something similar ... is it possible ?