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

View File

@ -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) void utf8ToWchar(const char *in, wchar_t *out, const u64 len)
{ {
#ifdef _WIN32 switch ( sizeof(wchar_t) )
PHYSFS_utf8ToUcs2(in, (u16 *) out, len); {
#else case 2: PHYSFS_utf8ToUcs2(in, (u16 *) out, len); break;
PHYSFS_utf8ToUcs4(in, (u32 *) out, len); case 4: PHYSFS_utf8ToUcs4(in, (u32 *) out, len); break;
#endif }
} }
void wcharToUtf8(const wchar_t *in, char *out, const u64 len) void wcharToUtf8(const wchar_t *in, char *out, const u64 len)
{ {
#ifdef _WIN32 switch ( sizeof(wchar_t) )
PHYSFS_utf8FromUcs2((const u16 *) in, out, len); {
#else case 2: PHYSFS_utf8FromUcs2((const u16 *) in, out, len); break;
PHYSFS_utf8FromUcs4((const u32 *) in, out, len); case 4: PHYSFS_utf8FromUcs4((const u32 *) in, out, len); break;
#endif }
} }
} // end namespace core } // end namespace core
} // end namespace irr } // end namespace irr