binary-data

getting an Int/short/byte structure byte representation with C#

戏子无情 提交于 2020-01-04 13:35:20
问题 Given a FieldInfo object and an object, I need to get the actual bytes representation of the field. I know that the field is either int,Int32,uint,short etc. How can I get the actual byte representation? BinaryFormatter.Serialize won't help, since it'll give me more information than I need (it also records type name etc.). The Marshal class does not seem to have facilities to use bytes array (but maybe I'm missing something). Thanks 回答1: You may also try code like the following if what you

Handling BLOBs in Entity Framework 4.0 in a stream-fashion

戏子无情 提交于 2020-01-03 08:45:21
问题 Is it possible to handle (read and write) binary data to SQL Server using Entity Framework 4.0 using streams? (i.e.: not the whole content shipped in a byte array) An example could be taken from Download and Upload images from SQL Server via ASP.Net MVC which illustrates the way to stream nicely data from SQL Server in an example available for ASP.NET MVC. However it requires direct access to the DB and I am curious whether this could be done using an ORM. 回答1: Unfortunately, this is not

Read binary file which has different datatypes

一个人想着一个人 提交于 2020-01-03 03:47:06
问题 Attempting to read a binary file produced in Fortran into Python, which has some integers, some reals and logicals. At the moment I read the first few numbers correctly with: x = np.fromfile(filein, dtype=np.int32, count=-1) firstint= x[1] ... (np is numpy). But the next item is a logical. And later on ints again and after reals. How can I do it? 回答1: Typically, when you're reading in values such as this, they're in a regular pattern (e.g. an array of C-like structs). Another common case is a

determine if blob is an image without loading entire field?

 ̄綄美尐妖づ 提交于 2020-01-02 08:05:10
问题 is there a way to read only a few bytes out of a BLOB type field in a database (for this question it doesn't matter the DB brand) and determine if the binary content is an image (assume it is one of: JPG, GIF, PNG)? I have a webapp that stores files in the database, and if it is an image, I want to show a thumbnail, otherwise I want to show an icon... but I don't have any MIMETYPE info stored anywhere else for the blob (it's not my design)... and because it is a webapp, the loading of the

There are a “binary dump” or “get binary representation” function in LibXML2?

£可爱£侵袭症+ 提交于 2020-01-01 18:58:22
问题 I need to access the internal binary representation of a loaded XML DOM... There are some dump functions, but I not see something like "binary buffer" (there are only "XML buffers"). My last objective is to compare byte-by-byte, the same document , before and after some black-box procedure , directly with their binary (current and cached) representations, without convertion (to XML-text representation)... So, the question, There are a binary representation (in-memory structures) in LibXML2,

Python search and replace in binary file

若如初见. 提交于 2020-01-01 07:52:48
问题 I am trying to search and replace some of the text (eg 'Smith, John') in this pdf form file (header.fdf, I presumed this is treated as binary file): '%FDF-1.2\n%\xe2\xe3\xcf\xd3\n1 0 obj\n<</FDF<</Fields[<</V(M)/T(PatientSexLabel)>><</V(24-09-1956 53)/T(PatientDateOfBirth)>><</V(Fisher)/T(PatientLastNameLabel)>><</V(CNSL)/T(PatientConsultant)>><</V(28-01-2010 18:13)/T(PatientAdmission)>><</V(134 Field Street\\rBlackburn BB1 1BB)/T(PatientAddressLabel)>><</V(Smith, John)/T(PatientName)>><</V

Python search and replace in binary file

老子叫甜甜 提交于 2020-01-01 07:51:27
问题 I am trying to search and replace some of the text (eg 'Smith, John') in this pdf form file (header.fdf, I presumed this is treated as binary file): '%FDF-1.2\n%\xe2\xe3\xcf\xd3\n1 0 obj\n<</FDF<</Fields[<</V(M)/T(PatientSexLabel)>><</V(24-09-1956 53)/T(PatientDateOfBirth)>><</V(Fisher)/T(PatientLastNameLabel)>><</V(CNSL)/T(PatientConsultant)>><</V(28-01-2010 18:13)/T(PatientAdmission)>><</V(134 Field Street\\rBlackburn BB1 1BB)/T(PatientAddressLabel)>><</V(Smith, John)/T(PatientName)>><</V

Delimiting binary sequences

妖精的绣舞 提交于 2019-12-30 02:53:05
问题 I need to be able to delimit a stream of binary data. I was thinking of using something like the ASCII EOT (End of Transmission) character to do this. However I'm a bit concerned -- how can I know for sure that the particular binary sequence used for this (0b00000100) won't appear in my own binary sequences, thus giving a false positive on delimitation? In other words, how is binary delimiting best handled? EDIT: ...Without using a length header. Sorry guys, should have mentioned this before.

How to Create a Single Dummy Variable with conditions in multiple columns?

老子叫甜甜 提交于 2019-12-29 01:31:30
问题 I am trying to efficiently create a binary dummy variables (1/0) in my data set based on whether or not one or more of 7 variables (col9-15) in the data set take on a specific value (35), but I don't want to test all columns. While as.numeric is ideal usually, I can only get it to work with one column at a time: data$indicator <- as.numeric(data$col1 == 35) Any idea how I can modify the above code so that if any of data$col9 - data$col15 are "35" then my indicator variable takes on a 1?

Are there any Java Frameworks for binary file parsing?

↘锁芯ラ 提交于 2019-12-28 10:45:08
问题 My problem is, that I want to parse binary files of different types with a generic parser which is implemented in JAVA. Maybe describing the file format with a configuration file which is read by the parser or creating Java classes which parse the files according to some sort of parsing rules. I have searched quite a bit on the internet but found almost nothing on this topic. What I have found are just things which deal with compiler-generators (Jay, Cojen, etc.) but I don't think that I can