Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated WCS4_UTF16 to allow four octet wchar_t characters to marshal … #2146

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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;
--length;
return this->write_measured_wchar_array (cdr, x, len, length);
}
}
Expand Down
Loading