fix UTF16/UTF32Encoding wrong byte order handling on bigendian

This commit is contained in:
Günter Obiltschnig 2020-02-08 20:25:00 +01:00
parent 137c6ad136
commit 4092984256
2 changed files with 57 additions and 51 deletions

View File

@ -124,7 +124,7 @@ int UTF16Encoding::convert(const unsigned char* bytes) const
if (_flipBytes)
{
ByteOrder::flipBytes(uc);
uc = ByteOrder::flipBytes(uc);
}
if (uc >= 0xd800 && uc < 0xdc00)
@ -136,7 +136,7 @@ int UTF16Encoding::convert(const unsigned char* bytes) const
if (_flipBytes)
{
ByteOrder::flipBytes(uc2);
uc2 = ByteOrder::flipBytes(uc2);
}
if (uc2 >= 0xdc00 && uc2 < 0xe000)
{
@ -202,7 +202,9 @@ int UTF16Encoding::queryConvert(const unsigned char* bytes, int length) const
*p++ = *bytes++;
*p++ = *bytes++;
if (_flipBytes)
ByteOrder::flipBytes(uc);
{
uc = ByteOrder::flipBytes(uc);
}
if (uc >= 0xd800 && uc < 0xdc00)
{
if (length >= 4)
@ -212,7 +214,9 @@ int UTF16Encoding::queryConvert(const unsigned char* bytes, int length) const
*p++ = *bytes++;
*p++ = *bytes++;
if (_flipBytes)
ByteOrder::flipBytes(uc2);
{
uc2 = ByteOrder::flipBytes(uc2);
}
if (uc2 >= 0xdc00 && uc < 0xe000)
{
ret = ((uc & 0x3ff) << 10) + (uc2 & 0x3ff) + 0x10000;

View File

@ -126,7 +126,7 @@ int UTF32Encoding::convert(const unsigned char* bytes) const
if (_flipBytes)
{
ByteOrder::flipBytes(uc);
uc = ByteOrder::flipBytes(uc);
}
return uc;
@ -161,7 +161,9 @@ int UTF32Encoding::queryConvert(const unsigned char* bytes, int length) const
*p++ = *bytes++;
*p++ = *bytes++;
if (_flipBytes)
ByteOrder::flipBytes(uc);
{
uc = ByteOrder::flipBytes(uc);
}
return uc;
}