Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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--;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefix decrement

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated commit just pushed. Let me know if you have other comments. Thanks!

length--;
return this->write_measured_wchar_array (cdr, x, len, length);
}
}
Expand Down