CompoundFileReader: fix UTF16~wstring conversion on 16b wchar compilers
This commit is contained in:
parent
430da67222
commit
c39dfb9f05
|
@ -102,25 +102,32 @@ template <typename T>
|
|||
std::wstring UTF16ToWstring(const T* u16, size_t len = 0)
|
||||
{
|
||||
std::wstring ret;
|
||||
#ifdef _MSC_VER
|
||||
while (*u16) ret += *u16++;
|
||||
#else
|
||||
if( sizeof( wchar_t ) == 2 )
|
||||
{
|
||||
while( *u16 )
|
||||
ret += *u16++;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t cp;
|
||||
size_t pos = 0;
|
||||
while( GetNextCodePointFromUTF16( u16, len, &pos, &cp ) )
|
||||
{
|
||||
ret += cp;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string WstringToUTF8(const T* wstr)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
if( sizeof( wchar_t ) == 2 )
|
||||
{
|
||||
return UTF16ToUTF8( wstr );
|
||||
#else
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string u8;
|
||||
uint32_t cp;
|
||||
while( ( cp = *wstr++ ) != 0 )
|
||||
|
@ -132,6 +139,7 @@ std::string WstringToUTF8(const T* wstr)
|
|||
u8 += static_cast<char>( c[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
return u8;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue