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:
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user