Fix StringUtils::ConvertANSI2UTF16 to properly handle multi-byte characters Length

#1225
This commit is contained in:
Wojtek Figat
2023-07-03 12:10:06 +02:00
parent 9a1fd12a85
commit 9d640656e6
9 changed files with 26 additions and 19 deletions

View File

@@ -49,7 +49,7 @@ public:
{
}
StringAsANSI(const Char* text, const int32 length)
StringAsANSI(const Char* text, int32 length)
{
if (length + 1 < InlinedSize)
{
@@ -83,7 +83,7 @@ public:
{
}
StringAsUTF8(const Char* text, const int32 length)
StringAsUTF8(const Char* text, int32 length)
{
int32 lengthUtf8;
if (length + 1 < InlinedSize)
@@ -112,17 +112,17 @@ public:
{
}
StringAsUTF16(const char* text, const int32 length)
StringAsUTF16(const char* text, int32 length)
{
if (length + 1 < InlinedSize)
{
StringUtils::ConvertANSI2UTF16(text, this->_inlined, length);
StringUtils::ConvertANSI2UTF16(text, this->_inlined, length, length);
this->_inlined[length] = 0;
}
else
{
this->_dynamic = (CharType*)Allocator::Allocate((length + 1) * sizeof(CharType));
StringUtils::ConvertANSI2UTF16(text, this->_dynamic, length);
StringUtils::ConvertANSI2UTF16(text, this->_dynamic, length, length);
this->_dynamic[length] = 0;
}
}