decode

Reading double to platform endianness with union and bit shift, is it safe?

末鹿安然 提交于 2019-12-05 20:13:39
All the examples I've seen of reading a double of known endianness from a buffer to the platform endianness involve detecting the current platform's endianess and performing byte-swapping when necessary. On the other hand, I've seen another way of doing the same thing except for integers that uses bit shifting ( one such example ). This got me thinking that it might be possible to use a union and the bitshift technique to read doubles (and floats) from buffers, and a quick test implementation seemed to work (at least with clang on x86_64): #include <stdio.h> #include <stdint.h> #include

Decoding and matching Chip 8 opcodes in C/C++

▼魔方 西西 提交于 2019-12-05 16:28:42
I'm writing a Chip 8 emulator as an introduction to emulation and I'm kind of lost. Basically, I've read a Chip 8 ROM and stored it in a char array in memory. Then, following a guide, I use the following code to retrieve the opcode at the current program counter (pc): // Fetch opcode opcode = memory[pc] << 8 | memory[pc + 1]; Chip 8 opcodes are 2 bytes each. This is code from a guide which I vaguely understand as adding 8 extra bit spaces to memory[pc] (using << 8) and then merging memory[pc + 1] with it (using |) and storing the result in the opcode variable. Now that I have the opcode

android fastest way to decode mp3 to pcm data

徘徊边缘 提交于 2019-12-05 16:15:48
in my app i need to decode an mp3 file into a pcm buffer. that's a lot of data so i downsample it to mono 22050Hz as i read and decode it. at the moment i'm using javazoom jlayer decoder http://www.javazoom.net/javalayer/javalayer.html its working but its slow, 30secs to decode a 3min song in run mode, ages in debug mode. on my windows machine using libmpg i can do that in about 1 second. is there a faster way that anyone knows for sure is faster? i don't want to waste time implementing another method if its not significantly faster. thanks. by the way, in my app, i need the whole thing

UnicodeDecodeError on byte type

谁都会走 提交于 2019-12-05 15:41:47
Using Python 3.4 I'm getting the following error when trying to decode a byte type using utf-32 Traceback (most recent call last): File "c:.\SharqBot.py", line 1130, in <module> fullR=s.recv(1024).decode('utf-32').split('\r\n') UnicodeDecodeError: 'utf-32-le' codec can't decode bytes in position 0-3: codepoint not in range(0x110000) and the following when trying to decode it into utf-16 File "c:.\SharqBot.py", line 1128, in <module> fullR=s.recv(1024).decode('utf-16').split('\r\n') UnicodeDecodeError: 'utf-16-le' codec can't decode byte 0x0a in position 374: truncated data When I decode using

c++ decode CCITT encoded images in pdfs

元气小坏坏 提交于 2019-12-05 12:45:56
I'm trying to extract all images out of PDF files in C++. I'm stuck in decoding CCITT encoded images. Does anyone know an opensourced code for this? I use the ImageMagick Magick++ Library, is it possible to do the decoding with this library, too? Thanks for your help! CCITT is one of the encodings TIFF supports, though in a PDF file the CCITT images are probably raw data. You can convert a raw CCITT image into a Tiff image using Fax2Tiff . It should be easy enough to work with the image once it is encoded as a Tiff. Fax2Tiff is part of LibTiff. See LibTiff Source Or you can append a header on

Decoding ampersand hash strings (&#124&#120&#97)etc

*爱你&永不变心* 提交于 2019-12-05 10:40:15
The solutions in other answers do not work when I try them, the same string outputs when I try those methods. I am trying to do web scraping using Python 2.7. I have the webpage downloaded and it has some characters which are in the form &#120 where 120 seems to represent the ascii code. I tried using HTMLParser() and decode() methods but nothing seems to work. Please note that what I have from the webpage in the format are only those characters. Example: &#66&#108&#97&#115&#116&#101&#114&#106&#97&#120&#120&#32 Please guide me to decode these strings using Python. I have read the other answers

解决超长内容加密失败解决方案

巧了我就是萌 提交于 2019-12-05 06:25:22
来自:https://www.itread01.com/p/1452444.html java rsa 解密 報:javax.crypto.IllegalBlockSizeException: Data must not be longer than 117 bytes java教程 · 發表 2018-10-08 Exception in thread "main" javax.crypto.IllegalBlockSizeException: Data must not be longer than 117 bytes at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:344) at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:389) at javax.crypto.Cipher.doFinal(Cipher.java:2165) at com.asymmetric.rsa.TestRSA.testDecrypt(TestRSA.java:82) at com.asymmetric.rsa.TestRSA.main(TestRSA.java:33) 異常解釋 加密塊大小錯誤,rsa 加密 塊大小為117 ,解密塊大小為128

Decode JSON with jQuery / AJAX

与世无争的帅哥 提交于 2019-12-05 05:18:04
I'm trying to decode a JSON with jQuery. Here's what I get (for instance a class, here with one student): "{"Students":[{"Name":John,"Grade":17,}],"TotalClass":17,"TotalCount":1,}" here's what I do: $j.ajax({ type: 'POST', url: 'class.aspx/getClass', contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (msg) { $j.each(msg, function (index, element) { alert(element.TotalClass); }); }, }); It keeps saying undefined in the alert (but I recieve the right JSON). Any idea what I'm doing wrong? {"Students":[{"Name":John,"Grade":17,}],"TotalClass":17,"TotalCount":1,} is

Add overlays to video on Android [closed]

China☆狼群 提交于 2019-12-05 04:55:46
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I'm developing an Android application, this application load video file from android gallery that saved on SD Card. I need to know how can I add overlays to this video I need to add title and image on this video like brand images I can not find an example or tutorial describe how

Using decode() vs. regex to unescape this string

此生再无相见时 提交于 2019-12-05 04:21:44
I have the following string and I'm trying to figure out the best practice for unescaping it. The solution has to be somewhat flexible in that I'm receiving this input from an API and I can't be absolutely certain that the current character structure ( \n as opposed to \r ) will always be the same. '"If it ain\'t broke, don\'t fix it." \nWent in for a detailed car wash.\nThe attendants raved-up my engine when taking the car into the tunnel. NOTE: my car is...' This regex seems like it should work: text_excerpt = re.sub(r'[\s"\\]', ' ', raw_text_excerpt).strip() I've aso read that decode()