binary-data

How to print float value from binary file in shell?

点点圈 提交于 2019-12-04 08:28:17
I've binary file consisting double float (8 bytes) or just float (4 bytes) value which was generated in the following way: $ python -c $'from struct import pack\nwith open("file.bin", "wb") as f: f.write(pack("<d", 0.123))' $ xxd file.bin 00000000: b072 6891 ed7c bf3f .rh..|.? which I could print it back from Python via: $ python -c $'from struct import unpack\nwith open("file.bin", "rb") as f: print(unpack("<d", f.read(8)))' (0.123,) The same for 4-byte float, just change <d into <f (mentioned as float.bin later on). How do I print that value from the shell script using cleaner way (without

Is there any perfomormance differences between binary and XML serialization?

喜欢而已 提交于 2019-12-04 07:42:12
in terms of both parsing (serializing, deserializing) and sending packets over the network is there any good estimation of performance differences between binary and xml serialization? Nope. It depends highly on what sort of data is inside the XML document itself. If you have a lot of structured data, the overhead for XML will be large. For example, if your data looks like: <person> <name>Dave</dave> <ssn>000-00-0000</ssn> <email1>xxxxxx/email1> </person> ... You'll have a lot more overhead than if you have an XML document that looks like: <book name="bible"> In the beginning God created the

MATLAB reading a mixed data type binary file

故事扮演 提交于 2019-12-04 06:29:41
问题 I am having trouble reading a very large binary file (1,000,000 bytes +) If I fread the file in a 1 byte data format for example 'uint8' the number of data read equals the size of the file so memory isn't an issue. I know in this binary file there is data of type 'int16' and 'single' however I don't know the structure of the file. I think the file is structured so there is an 'int16' data point followed by a 'single' data point and this is repeated until the end of the file. I do not know how

Ideal Field Type For Fixed Width Binary Data

时光怂恿深爱的人放手 提交于 2019-12-04 06:11:35
问题 If I want to store binary data (hash values) and they're always 128bytes long, what field type should I use? BLOB s are nice, but they aren't fixed width (and result in dynamic tables).. CHAR requires a charset. 回答1: You can use BINARY, so BINARY(128) . Note that if you're storing character data, then the standard character set of the operating system is used to convert the character to it's byte value, so you'd have to take any cross-platform issues into consideration. 来源: https:/

SQL Server 2000: how to save an Image variable to a file in the file system from a stored procedure

安稳与你 提交于 2019-12-04 06:10:05
问题 I have a stored procedure that receives a @Data image parameter. And I want to save it to the file system from a stored procedure. Any idea how to do it? 回答1: You can use OLE automation (ADODB.Stream) to write binary data from a SQL Server 2000 stored procedure, as described here and here. The sample below uses a varbinary variable, but it should work similarly with your image parameter. DECLARE @Path VarChar(255) DECLARE @Data VarBinary(1000) SET @Data = 0x12345678 SET @Path = 'c:\test.dat'

Save image from one format to another with php gd2

可紊 提交于 2019-12-04 05:27:13
问题 I have a database with a column filled with image binaries data. After I made some research I figuried out how to detect in which image format is the data. Lets say in of the records in my images column is in gif format, now I want to save it with php gd2 to jpeg format. Please, can someone tell me how can I do that? 回答1: If you only want to convert the image data to JPEG then all you need is imagecreatefromstring and imagejpeg. Basically: imagejpeg(imagecreatefromstring($gif_bindata), "temp

What is the difference between a Binary and a Bitstring in Erlang?

有些话、适合烂在心里 提交于 2019-12-04 05:05:19
In the Erlang shell, I can do the following: A = 300. 300 <<A:32>>. <<0, 0, 1, 44>> But when I try the following: B = term_to_binary({300}). <<131,104,1,98,0,0,1,44>> <<B:32>> ** exception error: bad argument <<B:64>> ** exception error: bad argument In the first case, I'm taking an integer and using the bitstring syntax to put it into a 32-bit field. That works as expected. In the second case, I'm using the term_to_binary BIF to turn the tuple into a binary, from which I attempt to unpack certain bits using the bitstring syntax. Why does the first example work, but the second example fail? It

Writing Byte Array To Binary File Javascript

旧巷老猫 提交于 2019-12-04 01:59:59
问题 I am trying to write a script that generates random numbers these number then are converted to groups of 4Bytes each then these 4-bytes-groups are put into an Uint8Array finally I try to save the array to binary file. Here is my code: <html> <head> <title>Raandom Number Generator</title> </head> <body> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script src="filesaver.min.js"></script> <script type="text/javascript"> $(function() { if (!Date.now) { Date.now = function(

Are there any characters that are not allowed in localStorage?

元气小坏坏 提交于 2019-12-04 01:42:43
问题 I've been using localStorage to store some binary data in string format, and although the value is definitely set ( alert ing it immediately after setting, or even some time after setting, shows the correct value) it is lost when the page next loads. At first I figured it might be because the data contained null bytes, so I redesigned the compressor so that it would never output them. However, this made no difference as the value is still lost. I added localStorage.testing = 1 immediately

How to best get a byte array from a ClientResponse from Spring WebClient?

主宰稳场 提交于 2019-12-04 00:14:25
I'm trying out the new WebClient from Spring 5 (5.0.0.RC2) in a codebase that uses reactive programming and I've had success mapping the JSON response from an endpoint to a DTO in my app, which works very nice: WebClient client = WebClient.create(baseURI); Mono<DTO> dto = client.get() .uri(uri) .accept(MediaType.APPLICATION_JSON) .exchange() .flatMap(response -> response.bodyToMono(DTO.class)); However, now I'm trying to the response body from an endpoint which uses Protocol Buffers (binary data served as application/octet-stream ), so I'd like to get the raw bytes from the response, which I