C testing framework. ASCII/Unicode portable version

Dimitrie O. Paun dimi at cs.toronto.edu
Wed Jan 23 13:25:46 CST 2002


On Wed, 23 Jan 2002, Alexandre Julliard wrote:

[snip]
> CopyFile( filename, _T("newfile"), FALSE );
> /* now test some Unicode chars */
> CopyFileW( filename, L"unicode_file_name", FALSE );
> 
> This won't work because you can't pass a TSTR to a W function. So you
> either need #ifdefs, or you need to use W functions and WCHAR
> throughout, which means you don't need TCHAR at all.

Ah, I see. We certainly need to get from generic to specific. So we can
have a bunch of funtions which do just that:

LPCSTR  strTtoA(LPCWSTR);  // converts the string to ANSI
LPCWSTR strTtoW(LPCSTR);   // converts the string to Unicode
LPCXSTR strTtoX(LPCTSTR);  // if T=A, convert to W, else convert to A

So the above example becomes:
  CopyFileW( strTtoW(filename), L"unicode_file_name", FALSE );

--
Dimi.





More information about the wine-devel mailing list