mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 22:54:34 +00:00
Provide a safer version of convertUTF16toUTF8
This commit is contained in:
parent
a88339c219
commit
e3bbc42925
10 changed files with 31 additions and 25 deletions
|
|
@ -79,7 +79,7 @@ static LRESULT PASCAL OKBtnFolderHackProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
|
|||
char *filePath;
|
||||
#ifdef UNICODE
|
||||
char fileBuf[MAX_PATH];
|
||||
convertUTF16toUTF8(ofn->lpstrFile, fileBuf, sizeof(fileBuf));
|
||||
convertUTF16toUTF8(ofn->lpstrFile, fileBuf);
|
||||
filePath = fileBuf;
|
||||
#else
|
||||
filePath = ofn->lpstrFile;
|
||||
|
|
@ -140,7 +140,7 @@ static UINT_PTR CALLBACK FolderHookProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPA
|
|||
|
||||
char filePath[MAX_PATH];
|
||||
#ifdef UNICODE
|
||||
convertUTF16toUTF8(buf, filePath, sizeof(filePath));
|
||||
convertUTF16toUTF8(buf, filePath);
|
||||
#else
|
||||
dStrcpy( filePath, buf );
|
||||
#endif
|
||||
|
|
@ -158,7 +158,7 @@ static UINT_PTR CALLBACK FolderHookProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPA
|
|||
|
||||
#ifdef UNICODE
|
||||
char buf2[MAX_PATH];
|
||||
convertUTF16toUTF8(buf, buf2, sizeof(buf2));
|
||||
convertUTF16toUTF8(buf, buf2);
|
||||
#else
|
||||
char *buf2 = buf;
|
||||
#endif
|
||||
|
|
@ -442,7 +442,7 @@ bool FileDialog::Execute()
|
|||
// Handle Result Properly for Unicode as well as ANSI
|
||||
#ifdef UNICODE
|
||||
if(pszFileTitle[0] || ! ( mData.mStyle & FileDialogData::FDS_OPEN && mData.mStyle & FileDialogData::FDS_MULTIPLEFILES ))
|
||||
convertUTF16toUTF8( (UTF16*)pszFile, (UTF8*)pszResult, sizeof(pszResult));
|
||||
convertUTF16toUTF8( (UTF16*)pszFile, pszResult);
|
||||
else
|
||||
convertUTF16toUTF8DoubleNULL( (UTF16*)pszFile, (UTF8*)pszResult, sizeof(pszResult));
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -588,7 +588,7 @@ const char* DInputDevice::getName()
|
|||
{
|
||||
#ifdef UNICODE
|
||||
static UTF8 buf[512];
|
||||
convertUTF16toUTF8(mDeviceInstance.tszInstanceName, buf, sizeof(buf));
|
||||
convertUTF16toUTF8(mDeviceInstance.tszInstanceName, buf);
|
||||
return (const char *)buf;
|
||||
#else
|
||||
return mDeviceInstance.tszInstanceName;
|
||||
|
|
@ -600,7 +600,7 @@ const char* DInputDevice::getProductName()
|
|||
{
|
||||
#ifdef UNICODE
|
||||
static UTF8 buf[512];
|
||||
convertUTF16toUTF8(mDeviceInstance.tszProductName, buf, sizeof(buf));
|
||||
convertUTF16toUTF8(mDeviceInstance.tszProductName, buf);
|
||||
return (const char *)buf;
|
||||
#else
|
||||
return mDeviceInstance.tszProductName;
|
||||
|
|
|
|||
|
|
@ -601,7 +601,7 @@ static bool recurseDumpPath(const char *path, const char *pattern, Vector<Platfo
|
|||
do
|
||||
{
|
||||
#ifdef UNICODE
|
||||
convertUTF16toUTF8( findData.cFileName, buf, buf.size );
|
||||
convertUTF16toUTF8N( findData.cFileName, buf, buf.size );
|
||||
char* fnbuf = buf;
|
||||
#else
|
||||
char *fnbuf = findData.cFileName;
|
||||
|
|
@ -1213,10 +1213,10 @@ void Platform::getVolumeInformationList( Vector<VolumeInformation>& out_rVolumeI
|
|||
|
||||
#ifdef UNICODE
|
||||
char buf[ sizeof( lpszFileSystem ) / sizeof( lpszFileSystem[ 0 ] ) * 3 + 1 ];
|
||||
convertUTF16toUTF8( lpszFileSystem, buf, sizeof( buf ) / sizeof( buf[ 0 ] ) );
|
||||
convertUTF16toUTF8( lpszFileSystem, buf );
|
||||
info.FileSystem = StringTable->insert( buf );
|
||||
|
||||
convertUTF16toUTF8( lpszVolumeName, buf, sizeof( buf ) / sizeof( buf[ 0 ] ) );
|
||||
convertUTF16toUTF8( lpszVolumeName );
|
||||
info.Name = StringTable->insert( buf );
|
||||
#else
|
||||
info.FileSystem = StringTable->insert( lpszFileSystem );
|
||||
|
|
@ -1276,7 +1276,7 @@ bool Platform::hasSubDirectory(const char *pPath)
|
|||
|
||||
#ifdef UNICODE
|
||||
char fileName[ 1024 ];
|
||||
convertUTF16toUTF8( findData.cFileName, fileName, sizeof( fileName ) / sizeof( fileName[ 0 ] ) );
|
||||
convertUTF16toUTF8( findData.cFileName, fileName );
|
||||
#else
|
||||
char* fileName = findData.cFileName;
|
||||
#endif
|
||||
|
|
@ -1397,7 +1397,7 @@ static bool recurseDumpDirectories(const char *basePath, const char *subPath, Ve
|
|||
continue;
|
||||
|
||||
#ifdef UNICODE
|
||||
convertUTF16toUTF8( findData.cFileName, fileName, fileName.size );
|
||||
convertUTF16toUTF8N( findData.cFileName, fileName, fileName.size );
|
||||
#else
|
||||
char* fileName = findData.cFileName;
|
||||
#endif
|
||||
|
|
@ -1472,7 +1472,7 @@ StringTableEntry osGetTemporaryDirectory()
|
|||
#ifdef UNICODE
|
||||
TempAlloc< char > dirBuffer( len * 3 + 1 );
|
||||
char* dir = dirBuffer;
|
||||
convertUTF16toUTF8( buffer, dir, dirBuffer.size );
|
||||
convertUTF16toUTF8N( buffer, dir, dirBuffer.size );
|
||||
#else
|
||||
char* dir = buf;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ BOOL CALLBACK EnumFamCallBack(LPLOGFONT logFont, LPNEWTEXTMETRIC textMetric, DWO
|
|||
|
||||
const U32 len = dStrlen( logFont->lfFaceName ) * 3 + 1;
|
||||
FrameTemp<UTF8> buffer( len );
|
||||
convertUTF16toUTF8( logFont->lfFaceName, buffer, len );
|
||||
convertUTF16toUTF8N( logFont->lfFaceName, buffer, len );
|
||||
|
||||
fonts->push_back( StringTable->insert( buffer ) );
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ const char *Platform::getUserDataDirectory()
|
|||
|
||||
#ifdef UNICODE
|
||||
char path[ MAX_PATH * 3 + 1 ];
|
||||
convertUTF16toUTF8( szBuffer, path, sizeof( path ) );
|
||||
convertUTF16toUTF8( szBuffer, path );
|
||||
#else
|
||||
char* path = szBuffer;
|
||||
#endif
|
||||
|
|
@ -78,7 +78,7 @@ const char *Platform::getUserHomeDirectory()
|
|||
|
||||
#ifdef UNICODE
|
||||
char path[ MAX_PATH * 3 + 1 ];
|
||||
convertUTF16toUTF8( szBuffer, path, sizeof( path ) );
|
||||
convertUTF16toUTF8( szBuffer, path );
|
||||
#else
|
||||
char* path = szBuffer;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -720,13 +720,13 @@ String Platform::FS::getAssetDir()
|
|||
{
|
||||
TCHAR buf[ 2048 ];
|
||||
::GetModuleFileNameW( NULL, buf, sizeof( buf ) );
|
||||
convertUTF16toUTF8( buf, cen_buf, sizeof( cen_buf ) );
|
||||
convertUTF16toUTF8( buf, cen_buf );
|
||||
}
|
||||
else
|
||||
{
|
||||
TCHAR buf[ 2048 ];
|
||||
GetCurrentDirectoryW( sizeof( buf ) / sizeof( buf[ 0 ] ), buf );
|
||||
convertUTF16toUTF8( buf, cen_buf, sizeof( cen_buf ) );
|
||||
convertUTF16toUTF8( buf, cen_buf );
|
||||
return Path::CleanSeparators(cen_buf);
|
||||
}
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ S32 WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
|
|||
{
|
||||
TCHAR buf[ moduleNameSize ];
|
||||
GetModuleFileNameW( NULL, buf, moduleNameSize );
|
||||
convertUTF16toUTF8( buf, moduleName, moduleNameSize );
|
||||
convertUTF16toUTF8( buf, moduleName );
|
||||
}
|
||||
#else
|
||||
GetModuleFileNameA(NULL, moduleName, moduleNameSize);
|
||||
|
|
@ -440,7 +440,7 @@ S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
|
|||
{
|
||||
TCHAR buf[ moduleNameSize ];
|
||||
GetModuleFileNameW( NULL, buf, moduleNameSize );
|
||||
convertUTF16toUTF8( buf, moduleName, moduleNameSize );
|
||||
convertUTF16toUTF8( buf, moduleName );
|
||||
}
|
||||
#else
|
||||
GetModuleFileNameA(NULL, moduleName, moduleNameSize);
|
||||
|
|
@ -541,7 +541,7 @@ bool Platform::openWebBrowser( const char* webAddress )
|
|||
RegCloseKey( regKey );
|
||||
sHaveKey = true;
|
||||
|
||||
convertUTF16toUTF8(sWebKey,utf8WebKey,512);
|
||||
convertUTF16toUTF8(sWebKey,utf8WebKey);
|
||||
|
||||
#ifdef UNICODE
|
||||
char *p = dStrstr((const char *)utf8WebKey, "%1");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue