title: boost format yield different output for seemingly same strings
body: <p><strong>Background</strong> </p>
  
  <p>I am using the <strong>boost format library</strong> to format some text. My input is an <code>uint8_t</code> array. This is the code I used:</p>
  
  <pre><code>#include &lt;array&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  #include &lt;iostream&gt;
  #include &lt;boost/format.hpp&gt;
  
  int main(int ac, const char * av[]){
  
      std::string nameStr = "HELLO, WORLD";
      std::array&lt;uint8_t, 30&gt; nameArr={0x48, 0x45, 0x4e, 0x4c, 0x4f, 0x20, 0x46, 0x52, 0x45, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
      std::string convertedStr(std::begin(nameArr), std::end(nameArr));
  
      std::cout &lt;&lt; "nameStr.size():" &lt;&lt; nameStr.size() &lt;&lt; ", nameStr.length():" &lt;&lt; nameStr.length() &lt;&lt; ", nameStr:" &lt;&lt; nameStr &lt;&lt; std::endl;
      std::cout &lt;&lt; "convertedStr.size():" &lt;&lt; convertedStr.size() &lt;&lt; ", convertedStr.lenght():" &lt;&lt; convertedStr.length() &lt;&lt; ", convertedStr:" &lt;&lt; convertedStr &lt;&lt; std::endl;
  
      std::ostringstream oss;
      oss &lt;&lt; boost::format("%-24s%c%-10d%8s") % nameStr % "#" % 512 % "999";
  
      std::cout &lt;&lt; oss.str() + '\n';
  
      oss.str(std::string());
  
      oss &lt;&lt; boost::format("%-24s%c%-10d%8s") % convertedStr % "#" % 512 % "999";
  
      std::cout &lt;&lt; oss.str() + '\n';
  
      return 0;
  }
  </code></pre>
  
  <p><strong>Issue</strong></p>
  
  <p>The code above produce this output:</p>
  
  <pre><code>nameStr.size():10, nameStr.lenght():10, nameStr:HELLO, WORLD
  convertedStr.size():30, convertedStr.lenght():30, convertedStr:HELLO, WORLD
  HELLO, WORLD              #512            999
  HELLO, WORLD#512            999
  </code></pre>
  
  <p><code>oss &lt;&lt; boost::format("%-24s%c%-10d%8s") % convertedStr % "#" % 512 % "999";</code> gives a different output &amp; omits <code>-24</code> and starts following parts immediately.</p>
  
  <p>I <em>guessed</em> that length of array was bigger than format length specifier might cause this, so I changed <code>-24</code> to <code>-40</code> at both format lines. This is the output:</p>
  
  <pre><code>nameStr.size():10, nameStr.lenght():10, nameStr:HELLO, WORLD
  convertedStr.size():30, convertedStr.lenght():30, convertedStr:HELLO, WORLD
  HELLO, WORLD                              #512            999
  HELLO, WORLD          #512            999
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>Is there something wrong with my code?</p>
  
  <p>How can I format string converted from <code>uint8_t</code> array properly?</p>