Skip to content

Commit

Permalink
Updated WCS4_UTF16 to allow four octet wchar_t characters to marshal …
Browse files Browse the repository at this point in the history
…properly on Linux
  • Loading branch information
wkbrd committed Oct 17, 2023
1 parent 51e1e2c commit 5888aa9
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions TAO/tests/CodeSets/libs/UCS4_UTF16/WUCS4_UTF16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,17 @@ size_t count_potential_surrogates (
ACE_CDR::ULong len)
{
size_t count = 0;
for (size_t i = 0; i < len; ++i)
if (buffer)
{
// see comments above in encode_utf16().
unsigned long ul_value = static_cast<unsigned long>(buffer[i]);
if (ul_value >= ACE_UTF16_RAW_END &&
ul_value < ACE_UTF16_END)
for (size_t i = 0; i < len; ++i)
{
count += 1;
// see comments above in encode_utf16().
unsigned long ul_value = static_cast<unsigned long>(buffer[i]);
if (ul_value >= ACE_UTF16_RAW_END &&
ul_value < ACE_UTF16_END)
{
count += 1;
}
}
}
return count;
Expand Down Expand Up @@ -379,6 +382,11 @@ WUCS4_UTF16::read_wchar_array_i (ACE_InputCDR & cdr,
for (size_t xpos = 0; xpos < length; ++xpos)
{
x[xpos] = load_wchar (buf, bpos, length, byte_swap);
if ((x[xpos] == ACE_UNICODE_SUBSTITUTE_CHARACTER) && (bpos == length))
{
x[xpos] = 0;
break;
}
}

return 1;
Expand Down Expand Up @@ -486,9 +494,16 @@ WUCS4_UTF16::write_wstring (ACE_OutputCDR & cdr,
ACE_CDR::ULong length = len + count_potential_surrogates (x, len);
ACE_CDR::ULong l = length * ACE_UTF16_CODEPOINT_SIZE;

if(!x)
{
l = 0;
}

if (this->write_4 (cdr, &l) && x != 0)
{
this->write_2 (cdr, &bom);
len--;
length--;
return this->write_measured_wchar_array (cdr, x, len, length);
}
}
Expand Down

0 comments on commit 5888aa9

Please sign in to comment.