Wednesday, August 03, 2005

Useful header file for STL MBCS/Unicode portable code

#pragma once

#include <vector>
#include
<string>
#include
<fstream>

namespace std
{
// Define TCHAR compatible elements of string/iostream
#if defined _UNICODE || defined UNICODE
typedef wstring _tstring;
typedef wostream _tostream;
typedef wistream _tistream;
typedef wfstream _tfstream;
typedef wifstream _tifstream;
typedef wofstream _tofstream;

#define _tcout wcout
#define _tcin wcin
#define _tcerr wcerr
#define _tclog wclog
#else
typedef string _tstring;
typedef ostream _tostream;
typedef istream _tistream;
typedef fstream _tfstream;
typedef ifstream _tifstream;
typedef ofstream _tofstream;

#define _tcout cout
#define _tcin cin
#define _tcerr cerr
#define _tclog clog
#endif
}