detect endians from file that is loaded in a binarystream?

  1. 2 months ago

    Rich H

    Mar 26 Testers, Xojo Pro

    is there away to detect the endians of a binarystream if data was populated from a folderitem?

    it might since a memoryblock has an endianess property :)

  2. Norman P

    Mar 26 Testers, Xojo Pro outside LMAO !!!!!!!
    Edited 2 months ago

    is this structured data ?
    do you know some values that should be in there ?

    the reason I ask is if you know that there are some Uint32 with certain values that are supposed to be at specific offsets then they could be tested to see if they are big or little endian

    but if you know nothing about the data or its structure that could be hard
    its just bytes and they dont have any specific endianess in and of themselves
    only larger items like Int16 int32, int64 etc will

  3. Rich H

    Mar 26 Testers, Xojo Pro

    thank you norm.

    the files I am working with is DICOM files that have been stored in a PACS archive storage format that doesnt adhere to the standard. i am at a point where I can extract out the files from the archive format, but i am noticing that they have stripped out header details that is needed to make the file whole.

    Under normal circumstances, Transfer Syntax UID would be presented which would make it very easy for me to do a look up on a dictionary and see what type of compression and endians the file is. I just wasn't sure if Transfer Syntax is not presented if there was another way to check.

    I will need to research a bit more on the dicom standard if there are Uint32 values that needs to be a specific offset.

  4. Rich H

    Mar 26 Testers, Xojo Pro
    Edited 2 months ago

    ok, here is another question.

    in the code below, would this create a mess if dicomMB was Big Endian? dicomMB was populated from binarystream

    var emptyMB as new MemoryBlock(128) 
    var dicmMB as MemoryBlock = "DICM"
    var fixedMB as MemoryBlock
    if dicomMB.StringValue(128, 4) = "DICM" then
      return dicomMB
      fixedMB = emptyMB + dicmMB + dicomMB
      return fixedMB
    end if
  5. Norman P

    Mar 27 Testers, Xojo Pro Answer outside LMAO !!!!!!!

    it might since a memoryblock has an endianess property :)

  6. Rich H

    Mar 27 Testers, Xojo Pro

    thanks norm.

    already started making changes

or Sign Up to reply!