Re: [Quickfix-developers] Field with embedded null character
Brought to you by:
orenmnero
From: Caleb E. <cal...@gm...> - 2004-10-28 13:05:55
|
On Wed, 27 Oct 2004 21:23:04 -0400, Yihu Fang <yih...@re...> wrote: > However, in QuickFIX message constructor, it takes string as the parameter. > It will throw an invalid message exception because it thinks the string is > truncated at the null character and cannot find the Tag 10. Make sure you construct the string you pass to the Message constructor properly. The std::string constructor can take a const char* with or without a length. If you don't pass the length, it'll stop at the first embedded \0 and you'll end up with a truncated message. That said, it does seem that QuickFIX has a bug in the message serialization code when dealing with fields having embedded \0 bytes: #include <quickfix/Message.h> #include <iostream> using namespace FIX; using namespace std; int main () { Message m; m.setField (1000, string ("one\0", 4)); cout << m.toString () << endl; cout << m.getField (1000) << endl; } Gives the output (where ^A = ASCII SOH and \0 is an ASCII NULL) 9=10^A1000= one^A10=057^A one\0 Note extra space and lack of \0 for serialized message form. -- Caleb Epstein cal...@gm... |