utf8ToWchar and wcharToUtf8 work with sizeof checks instead of defines now to call correct conversion

Tiny speed hit, but old solution caused warnings. 
And it was not very safe by assuming all non _WIN32 platforms would use 32 bit sizes for wchar_t.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6290 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2022-01-08 15:19:46 +00:00
parent c2ff824550
commit 98aed6ba67

@ -359,22 +359,21 @@ static void PHYSFS_utf8FromUcs2(const u16 *src, char *dst, u64 len)
void utf8ToWchar(const char *in, wchar_t *out, const u64 len)
{
#ifdef _WIN32
PHYSFS_utf8ToUcs2(in, (u16 *) out, len);
#else
PHYSFS_utf8ToUcs4(in, (u32 *) out, len);
#endif
switch ( sizeof(wchar_t) )
{
case 2: PHYSFS_utf8ToUcs2(in, (u16 *) out, len); break;
case 4: PHYSFS_utf8ToUcs4(in, (u32 *) out, len); break;
}
}
void wcharToUtf8(const wchar_t *in, char *out, const u64 len)
{
#ifdef _WIN32
PHYSFS_utf8FromUcs2((const u16 *) in, out, len);
#else
PHYSFS_utf8FromUcs4((const u32 *) in, out, len);
#endif
switch ( sizeof(wchar_t) )
{
case 2: PHYSFS_utf8FromUcs2((const u16 *) in, out, len); break;
case 4: PHYSFS_utf8FromUcs4((const u32 *) in, out, len); break;
}
}
} // end namespace core
} // end namespace irr