diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index 3024e86a00..e12047947e 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -170,11 +170,11 @@ CString vssprintf( const char *fmt, va_list argList) #ifdef WIN32 #ifdef _XBOX -#include "D3DX8Core.h" +#include #else -#include "windows.h" -#include "Dxerr8.h" -#pragma comment(lib, "Dxerr8.lib") +#include +#include +#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) diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index 2fd1571bff..2869761a23 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -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.