From 5888aa90df0c25d67007531467f997550be94e9f Mon Sep 17 00:00:00 2001 From: wkbrd <30599409+wkbrd@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:15:32 -0400 Subject: [PATCH 1/2] Updated WCS4_UTF16 to allow four octet wchar_t characters to marshal properly on Linux --- .../CodeSets/libs/UCS4_UTF16/WUCS4_UTF16.cpp | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/TAO/tests/CodeSets/libs/UCS4_UTF16/WUCS4_UTF16.cpp b/TAO/tests/CodeSets/libs/UCS4_UTF16/WUCS4_UTF16.cpp index a8f749ecfdc0a..81df502aaf159 100644 --- a/TAO/tests/CodeSets/libs/UCS4_UTF16/WUCS4_UTF16.cpp +++ b/TAO/tests/CodeSets/libs/UCS4_UTF16/WUCS4_UTF16.cpp @@ -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(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(buffer[i]); + if (ul_value >= ACE_UTF16_RAW_END && + ul_value < ACE_UTF16_END) + { + count += 1; + } } } return count; @@ -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; @@ -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); } } From 5d1fa403916868eb8a499425a94cd7a363f5d8f9 Mon Sep 17 00:00:00 2001 From: wkbrd <30599409+wkbrd@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:16:45 -0400 Subject: [PATCH 2/2] Change to prefix decrement --- TAO/tests/CodeSets/libs/UCS4_UTF16/WUCS4_UTF16.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TAO/tests/CodeSets/libs/UCS4_UTF16/WUCS4_UTF16.cpp b/TAO/tests/CodeSets/libs/UCS4_UTF16/WUCS4_UTF16.cpp index 81df502aaf159..5379bebe29856 100644 --- a/TAO/tests/CodeSets/libs/UCS4_UTF16/WUCS4_UTF16.cpp +++ b/TAO/tests/CodeSets/libs/UCS4_UTF16/WUCS4_UTF16.cpp @@ -502,8 +502,8 @@ WUCS4_UTF16::write_wstring (ACE_OutputCDR & cdr, if (this->write_4 (cdr, &l) && x != 0) { this->write_2 (cdr, &bom); - len--; - length--; + --len; + --length; return this->write_measured_wchar_array (cdr, x, len, length); } }