<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="">0x0d is a carriage return. Someone is using character I/O somewhere. It’s possible they are appearing after ‘nul’ characters 0x00 bytes or some such.<div class=""><br class=""><div apple-content-edited="true" class="">
<div class="">George Watson</div><div class="">Principal, Sierra Computing</div><div class=""><a href="mailto:watson@sierracmp.com" class="">watson@sierracmp.com</a></div><div class=""><br class=""></div><br class="Apple-interchange-newline">

</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Dec 14, 2015, at 10:52 AM, Jerry Tol <<a href="mailto:jertol52@gmail.com" class="">jertol52@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello,<div class="">I'm implementing a gdal raster driver for an internal file format and am getting results I do not understand. The output is a binary raster of 32-bit floating point data, but the resulting file contains single bytes of value 0x0D at seemingly random intervals throughout the data. </div><div class=""><br class=""></div><div class="">Within my implementation of IWriteBlock, I see that the buffer pointed to by pImage <b class="">does not</b> contain these 0x0D's, however after calling <span style="font-family: Consolas;" class="">VSIFWrite </span>the output file does indeed have these individual bytes scattered throughout. In all cases, I am creating a new output file (not overwriting an existing file). Sometimes the 0D's occur in the middle of a 4-byte float, others are between two 4-byte float sequences. I cannot figure how/when/why these random 0D's are occurring in my output.</div><div class=""><br class=""></div><div class="">Thank you for any help provided. Here is my implementation of IWriteBlock</div><div class=""><pre style="font-family: Consolas; background-repeat: initial initial;" class="">CPLErr RLYRRasterBand::IWriteBlock(<span style="color:blue" class="">int</span> nBlockXOff, <span style="color:blue" class="">int</span> nBlockYOff, <span style="color:blue" class="">void</span> *pImage)
{
        RLYRDataset *poGDS = (RLYRDataset *)poDS;
        <span style="color:blue" class="">if</span> (poGDS->fp == 0) {
                CPLError(CE_Failure, CPLE_FileIO, <span style="color:rgb(163,21,21)" class="">"IWriteBlock: fp is NULL"</span>);
                <span style="color:blue" class="">return</span> CE_Failure;
        }
        nBlockYOff = poDS->GetRasterYSize() - nBlockYOff - 1;
 
        size_t cdtSize = GDALGetDataTypeSize(GetRasterDataType()) / 8;
        size_t nSeek = RLYRMeta::offset_data + 
                cdtSize * (nBlockXOff * nBlockYSize + nBlockYOff * nBlockXSize);
        <span style="color:blue" class="">int</span> zeeksez = VSIFSeek(poGDS->fp, nSeek, SEEK_SET);
        <span style="color:blue" class="">if</span> (zeeksez != 0) {
                CPLError(CE_Warning, CPLE_FileIO, <span style="color:rgb(163,21,21)" class="">"VSIFSeek returns %d"</span>, zeeksez);
                <span style="color:blue" class="">return</span> CE_Failure;
        }
 
        size_t nBlockLen = nBlockXSize * nBlockYSize;
        size_t nWrit = VSIFWrite(pImage, cdtSize, nBlockLen, poGDS->fp);
        <span style="color:blue" class="">if</span> (nWrit != nBlockLen) {
                CPLError(CE_Warning, CPLE_FileIO, <span style="color:rgb(163,21,21)" class="">"VSIFWrite returns %d"</span>, nWrit);
                <span style="color:blue" class="">return</span> CE_Failure;
        }
 
        <span style="color:green" class="">// test code - 'foo' does not exhibit bad data but the output file does</span>
        <span style="color:green" class="">//if (nBlockYOff == 1130) {</span>
        <span style="color:green" class="">// FILE *tfp = VSIFOpen("h:<a href="smb://rasters//o//foo" class="">\\rasters\\o\\foo</a>", "wb");</span>
        <span style="color:green" class="">// size_t nWrit2 = fwrite(pImage, cdtSize, nBlockLen, tfp);</span>
        <span style="color:green" class="">// VSIFClose(tfp);</span>
        <span style="color:green" class="">//}</span>
 
        <span style="color:blue" class="">return</span> CE_None;
}
</pre></div></div>
_______________________________________________<br class="">gdal-dev mailing list<br class=""><a href="mailto:gdal-dev@lists.osgeo.org" class="">gdal-dev@lists.osgeo.org</a><br class="">http://lists.osgeo.org/mailman/listinfo/gdal-dev</div></blockquote></div><br class=""></div></body></html>