<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 10, 2017, at 7:30 PM, 呂建德 <<a href="mailto:v0918732669@gmail.com" class="">v0918732669@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I test the same code on three platfoms like below.<div class=""><br class=""></div><div class=""><a href="http://imgur.com/a/9e38l" class="">http://imgur.com/a/9e38l</a></div><div class=""><br class=""></div><div class="">and the first one is mac os, second one is mint based on ubuntu16.04, the last one is ubuntu16.04 LTS.</div><div class=""><br class=""></div><div class="">the code in ndn-producer is </div><div class=""><div class="">data->setContent(::ndn::encoding::makeStringBlock(::ndn::tlv::Content, str));<br class=""></div></div><div class=""><br class=""></div><div class="">the code in ndn-consumer is</div><div class="">NS_LOG_INFO("< DATA for " << data->getContent().value());<br class=""></div></div></div></blockquote><div><br class=""></div><div><br class=""></div><div>This is not the proper way of interpreting content as a string.  This will try to interpret bytes carried in the content as a null-terminated string, which the content probably isn't.</div><div><br class=""></div><div>Use this, a bit more explicit, way:</div><div><br class=""></div><div>std::string stringValue(data->getContent().value(), data->getContent().value_size());</div><div><br class=""></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">I dont know what happened on these platforms, the same code ,the different result. orz</div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="gmail-h5"><br class=""></div></div>
</blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>