<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Limitations of binary mode and stream files in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/limitations-of-binary-mode-and-stream-files/m-p/3582668#M32406</link>
    <description>Ben,&lt;BR /&gt;C ANSI introduced on 1995 a new rule:&lt;BR /&gt;after backslash and x, programmer has to declare hex value with 4 characters to avoid confusion like your example: \xFFDEF where FFDE is a valid hex value.&lt;BR /&gt;The right declaration is \x00FFDEF.&lt;BR /&gt;I don't know if this is the troubel trouble, but you can quickly prove.&lt;BR /&gt; &lt;BR /&gt;Good luck.&lt;BR /&gt;Antonio Vigliotti&lt;BR /&gt;</description>
    <pubDate>Thu, 14 Jul 2005 08:07:44 GMT</pubDate>
    <dc:creator>Antoniov.</dc:creator>
    <dc:date>2005-07-14T08:07:44Z</dc:date>
    <item>
      <title>Limitations of binary mode and stream files</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/limitations-of-binary-mode-and-stream-files/m-p/3582667#M32405</link>
      <description>While working on the OpenVMS port of Ruby, I'm running into an apparent C runtime limitation of binary mode.&lt;BR /&gt;&lt;BR /&gt;A small ruby test illustrates the binary output problem:&lt;BR /&gt;&lt;BR /&gt;File.open('temp.tmp','wb') {|output| output.print "ABC\xFFDEF"}&lt;BR /&gt;$ dump temp.tmp            &lt;BR /&gt;Dump of file DSA0:[DM]TEMP.TMP;1 on 14-JUN-2005 11:05:43.87&lt;BR /&gt;File ID (201050,63,0)   End of file block 1 / Allocated 69&lt;BR /&gt;Virtual block number 1 (00000001), 512 (0200) bytes&lt;BR /&gt;00000000 00000000 00000000 00000000 00000000 00000000 00000000 FF434241 ABC............................. 000000&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;A C++ port of this test shows that this is not just Ruby's fault:&lt;BR /&gt;&lt;BR /&gt;#include &lt;IOSTREAM.H&gt;&lt;BR /&gt;#include &lt;FSTREAM.H&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt;   ofstream testf("test.dat");&lt;BR /&gt;   if(testf) {&lt;BR /&gt;      testf &amp;lt;&amp;lt; "ABC\0xFF DEF" &amp;lt;&amp;lt; endl;&lt;BR /&gt;   }&lt;BR /&gt;   testf.close();&lt;BR /&gt;   return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;This produces the same output as above.  That is, the "\0xFF" output to the stream file is considered an EOF, and the remaining output is discarded.&lt;BR /&gt;&lt;BR /&gt;Simply switching to a fixed, 512 byte record format is not an acceptable solution because then we lose the ability to write binary files that are a precise (non-512-multiple) number of bytes long.&lt;BR /&gt;&lt;BR /&gt;So, how do I get there from here?  How do I write binary files of arbitrary lengths?&lt;BR /&gt;&lt;BR /&gt;Ben&lt;BR /&gt;&lt;/FSTREAM.H&gt;&lt;/IOSTREAM.H&gt;</description>
      <pubDate>Thu, 14 Jul 2005 07:20:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/limitations-of-binary-mode-and-stream-files/m-p/3582667#M32405</guid>
      <dc:creator>Ben Armstrong</dc:creator>
      <dc:date>2005-07-14T07:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Limitations of binary mode and stream files</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/limitations-of-binary-mode-and-stream-files/m-p/3582668#M32406</link>
      <description>Ben,&lt;BR /&gt;C ANSI introduced on 1995 a new rule:&lt;BR /&gt;after backslash and x, programmer has to declare hex value with 4 characters to avoid confusion like your example: \xFFDEF where FFDE is a valid hex value.&lt;BR /&gt;The right declaration is \x00FFDEF.&lt;BR /&gt;I don't know if this is the troubel trouble, but you can quickly prove.&lt;BR /&gt; &lt;BR /&gt;Good luck.&lt;BR /&gt;Antonio Vigliotti&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Jul 2005 08:07:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/limitations-of-binary-mode-and-stream-files/m-p/3582668#M32406</guid>
      <dc:creator>Antoniov.</dc:creator>
      <dc:date>2005-07-14T08:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Limitations of binary mode and stream files</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/limitations-of-binary-mode-and-stream-files/m-p/3582669#M32407</link>
      <description>Ben,&lt;BR /&gt;&lt;BR /&gt;The problem in yours C++ example code is:&lt;BR /&gt;&lt;BR /&gt;testf &amp;lt;&amp;lt; "ABC\0xFF DEF" &amp;lt;&amp;lt; endl;&lt;BR /&gt;&lt;BR /&gt;instead of&lt;BR /&gt;&lt;BR /&gt;testf &amp;lt;&amp;lt; "ABC\xFF DEF" &amp;lt;&amp;lt; endl;&lt;BR /&gt;&lt;BR /&gt;Note the missing 0 in the second line. In yours code the \0 is translated as a null character and the string is terminated at this point.&lt;BR /&gt;&lt;BR /&gt;Bojan</description>
      <pubDate>Thu, 14 Jul 2005 09:11:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/limitations-of-binary-mode-and-stream-files/m-p/3582669#M32407</guid>
      <dc:creator>Bojan Nemec</dc:creator>
      <dc:date>2005-07-14T09:11:03Z</dc:date>
    </item>
  </channel>
</rss>

