How about putting the UTF-8 encoding / decoding in something along the
lines of decaf::util::UTF8::encode() and decaf::util::UTF8::decode()?
Both the AMQCPP client OpenwireStringSupport class and the
Data[Input|Output]Stream classes could use this common piece of code,
and thus avoiding code duplication.
Unless of course you *really* mean that AMQCPP can not depend on decaf :).
Timothy Bish (JIRA) wrote:
[ https://issues.apache.org/activemq/browse/AMQCPP-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=51312#action_51312 ]
Timothy Bish commented on AMQCPP-235:
-------------------------------------
Thanks for the input. Combining the code would have been ideal but I'm planning on splitting the decaf library out at some point into its own lib for use on some other projects so the AMQCPP client can't depend on that code so I kept them separate.
UTF8 length marshalling bug in openwire readString and writeString.
-------------------------------------------------------------------
Key: AMQCPP-235
URL: https://issues.apache.org/activemq/browse/AMQCPP-235
Project: ActiveMQ C++ Client
Issue Type: Bug
Components: Openwire
Environment: Windows XP / Visual Studio 2005
Reporter: Martin Schlapfer
Assignee: Timothy Bish
Priority: Minor
Fix For: 2.2.6, 3.0
Attachments: OpenwireStringSupport.cpp.patch,
OpenwireStringSupportTest.cpp.patch, OpenwireStringSupportTest.h.patch
In investigating a bug for the check "if( str->size() > 65536 )" which should be "if(
str->size() > 65535 )" in writeString() , I found a couple of other problems:
(1) The OpenwireStringSupport::readString method should read the utf8 length as
an unsigned short rather than short. The problem is that utf8 encoded strings
(using writeString) longer than 32768 will become truncated when read back
using readString().
(2) The writeString() method should also check the value of utflen after
determining the UTF8 length of the encoded string, since with the support of
characters greater than value 127, encodings of 2 UTF8 bytes per byte can exist.