ACP conversion. (This and hr_ and werr_ssprintf don't really belong in here,

I'll clean it up eventually ...)
This commit is contained in:
Glenn Maynard
2004-09-20 00:03:09 +00:00
parent 9bf052492f
commit 207a02dd08
2 changed files with 28 additions and 4 deletions
+26 -4
View File
@@ -170,11 +170,11 @@ CString vssprintf( const char *fmt, va_list argList)
#ifdef WIN32
#ifdef _XBOX
#include "D3DX8Core.h"
#include <D3DX8Core.h>
#else
#include "windows.h"
#include "Dxerr8.h"
#pragma comment(lib, "Dxerr8.lib")
#include <windows.h>
#include <dxerr8.h>
#pragma comment(lib, "dxerr8.lib")
#endif
CString hr_ssprintf( int hr, const char *fmt, ...)
@@ -216,6 +216,28 @@ CString werr_ssprintf( int err, const char *fmt, ...)
return s += ssprintf( " (%s)", text.c_str() );
}
CString ConvertWstringToACP( wstring s )
{
if( s.empty() )
return "";
int iBytes = WideCharToMultiByte( CP_ACP, 0, s.data(), s.size(),
NULL, 0, NULL, FALSE );
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "WideCharToMultiByte" ).c_str() );
CString ret;
WideCharToMultiByte( CP_ACP, 0, s.data(), s.size(),
ret.GetBuf( iBytes ), iBytes, NULL, FALSE );
ret.RelBuf( iBytes );
return ret;
}
CString ConvertUTF8ToACP( CString s )
{
return ConvertWstringToACP( CStringToWstring(s) );
}
#endif
CString join( const CString &Deliminator, const CStringArray& Source)
+2
View File
@@ -192,6 +192,8 @@ CString vssprintf( const char *fmt, va_list argList );
#ifdef WIN32
CString hr_ssprintf( int hr, const char *fmt, ...);
CString werr_ssprintf( int err, const char *fmt, ...);
CString ConvertWstringToACP( wstring s );
CString ConvertUTF8ToACP( CString s );
#endif
// Splits a Path into 4 parts (Directory, Drive, Filename, Extention). Supports UNC path names.