与UNICODE的字符大全
下面是在UNICODE编程环境下的字符的相关操作,请切记。
很有用处的!!!!!!!
/* ++++++++++++++++++++ UNICODE ++++++++++++++++++++ */
#define _TEOF WEOF
#define _tmain wmain
#ifdef UNDER_CE
#define _tWinMain WinMain // On CE it's always WinMain
#else
#define _tWinMain wWinMain
#endif
/* Formatted i/o */
#define _tprintf wprintf
#define _ftprintf fwprintf
#define _stprintf swprintf
#define _sntprintf _snwprintf
#define _vtprintf vwprintf
#define _vftprintf vfwprintf
#define _vstprintf vswprintf
#define _vsntprintf _vsnwprintf
#define _tscanf wscanf
#define _ftscanf fwscanf
#define _stscanf swscanf
/* Unformatted i/o */
#define _fgettc fgetwc
#define _fgetts fgetws
#define _fputtc fputwc
#define _fputts fputws
#define _gettc getwc
#define _gettchar getwchar
#define _getts _getws
#define _puttc putwc
#define _puttchar putwchar
#define _putts _putws
#define _ungettc ungetwc
// Stdio functions
#define _tfopen _wfopen
#define _tfreopen _wfreopen
/* String conversion functions */
#define _tcstod wcstod
#define _tcstol wcstol
#define _tcstoul wcstoul
#define _itot _itow
#define _ltot _ltow
#define _ultot _ultow
#define _ttoi _wtoi
#define _ttol _wtol
#define _ttoi64 _wtoi64
/* String functions */
#define _tcscat wcscat
#define _tcschr wcschr
#define _tcscmp wcscmp
#define _tcscpy wcscpy /////这个是将字符串1 copy 到字符串2
#define _tcscspn wcscspn
#define _tcslen wcslen
#define _tcsclen wcslen
#define _tcsncat wcsncat
#define _tcsnccat wcsncat
#define _tcsnccmp wcsncmp
#define _tcsncmp wcsncmp
#define _tcsncpy wcsncpy
#define _tcsnccpy wcsncpy
#define _tcspbrk wcspbrk
#define _tcsrchr wcsrchr
#define _tcsspn wcsspn
#define _tcsstr wcsstr
#define _tcstok wcstok
#define _tcsdup _wcsdup
#define _tcsicmp _wcsicmp
#define _tcsncicmp _wcsnicmp
#define _tcsnicmp _wcsnicmp
#define _tcsnset _wcsnset
#define _tcsncset _wcsnset
#define _tcsrev _wcsrev
#define _tcsset _wcsset
#define _tcslwr _wcslwr
#define _tcsupr _wcsupr
// ctype functions
#define _istalpha iswalpha
#define _istupper iswupper
#define _istlower iswlower
#define _istdigit iswdigit
#define _istxdigit iswxdigit
#define _istspace iswspace
#define _istpunct iswpunct
#define _istalnum iswalnum
#define _istprint iswprint
#define _istgraph iswgraph
#define _istcntrl iswcntrl
#define _istascii iswascii
#define _totupper towupper
#define _totlower towlower
#define _istlegal(_c) (1)
#define _istlead(_c) (0)
#define _istleadbyte(_c) (0)
#else /* ndef UNICODE */
实例部分用法:
void DoWithDSPFile(LPTSTR szDSPFileName)
{
VC::VCProjectEnginePtr ptrVC(__uuidof(
VC::VCProjectEngineObject));
// for project conversion
EnvDTE::ProjectItemPtr proj; // not used
VC::VCProjectPtr ptrProject; // smart ptr to project
TCHAR szCurDir[_MAX_PATH]; // full path to current
// directory
_bstr_t bstrCD; // smart bstring version of
// the above
TCHAR szVCProj[_MAX_PATH]; // full path to the new
// .vcproj file
_bstr_t bstrVCProj; // bstr version of above
TCHAR szDSP[_MAX_PATH]; // full path to the old .dsp
// file to convert
TCHAR szBareVCProj[_MAX_PATH]; // bare VCProj project name
// with eg myproj.vcproj
TCHAR szSoln[_MAX_PATH]; // solution
TCHAR szBareName[_MAX_PATH]; // solution bare name
_bstr_t bstrBareSoln; // bare (base) solution name
TCHAR* p; // pointer to a subsbring
// grab our directory
_tgetcwd(szCurDir, _MAX_PATH);
bstrCD = szCurDir;
_tcscpy(szVCProj, szCurDir);
PathAddBackslash(szVCProj);
// add original name
_tcscat(szVCProj, szDSPFileName);
// replace extension with .vcproj
p = PathFindExtension(szVCProj);
_tcscpy(p, _T(".vcproj"));
// did we already do it?
if (PathFileExists(szVCProj))
{
// tell the user & go to next file
_ftprintf(stdout, _T("Skipping %s because already converted/n"),
szVCProj);
return;
}
// OK using smart pointers here, need try/catch
try
{
// get full path to DSP file
_tcscpy(szDSP, szCurDir);
PathAddBackslash(szDSP);
_tcscat(szDSP, szDSPFileName);
// load old dsp file
ptrProject = ptrVC->LoadProject(szDSP);
// generate name from .DSP name (same base name)
_tcscpy(szBareVCProj, szDSPFileName);
p = PathFindExtension(szBareVCProj);
_tcscpy(p, _T(".vcproj"));
// name the project as proj.vcproj
ptrProject->PutProjectFile(szBareVCProj);
// save converted project (this will create the .vcproj file
ptrProject->Save();
// need to worry about creating a solution (.sln) file.
// This was the hard part to figure out.
_tcscpy(szSoln, szDSPFileName);
p = PathFindExtension(szSoln);
_tcscpy(p, _T(".sln"));
_tgetcwd(szCurDir, _MAX_PATH);
// create empty solution
EnvDTE::_SolutionPtr ptrSoln(_T("VisualStudio.Solution.7.1"));
// get the bare name for the solution
_tcscpy(szBareName, szDSPFileName);
p = PathFindExtension(szBareName);
*p = 0; // cut off at extension
// get a bstring
bstrBareSoln = szBareName;
// and create the empty solution
ptrSoln->Create(bstrCD, bstrBareSoln);
// get the filename of our new solution
bstrVCProj = szVCProj;
// and add it into the newly created solution, replacing
// whatever was there
ptrSoln->AddFromFile(bstrVCProj, FALSE,
(EnvDTE::Project**)&proj);
_ftprintf(stdout, _T("Project %s converted OK/n"), szVCProj);
}
catch(...)
{
_ftprintf(stdout, _T("Something bad happened.../n"));
}
}
本文地址:http://www.45fan.com/a/question/72390.html