decoding

Decoding URI query string in Java

喜你入骨 提交于 2019-11-26 22:53:16
问题 I need to decode a URI that contains a query string; expected input/output behavior is something like the following: abstract class URIParser { /** example input: * something?alias=pos&FirstName=Foo+A%26B%3DC&LastName=Bar */ URIParser(String input) { ... } /** should return "something" for the example input */ public String getPath(); /** should return a map * {alias: "pos", FirstName: "Foo+A&B=C", LastName: "Bar"} */ public Map<String,String> getQuery(); } I've tried using java.net.URI, but

Decoding URL parameters with JavaScript

微笑、不失礼 提交于 2019-11-26 22:38:25
This should be a simple task, but I can't seem to find a solution. I have a basic string that is being passed through as a query string parameter like this one: This+is+a+message+with+spaces . I would like to decode that parameter using JavaScript to This is a message with spaces , but I cannot seem to get it to decode. I've tried decodeURI('This+is+a+message+with+spaces') but the result still contains the + signs. Yes it is true that decodeURIComponent function doesn't convert + to space. So you have to replace the + using replace function. Ideally the below solution works. var str_name =

NodeJS: How to decode base64 encoded string back to binary? [duplicate]

不羁岁月 提交于 2019-11-26 21:23:36
This question already has an answer here: How to do Base64 encoding in node.js? 4 answers I was implementing password hashing with salt, so I generated salt as binary, hashed the password, base64 encoded the password and salt then stored them into database. Now when I am checking password, I am supposed to decode the salt back into binary data, use it to hash the supplied password, base64 encode the result and check if the result matches the one in database. The problem is, I cannot find a method to decode the salt back into binary data. I encoded them using the Buffer.toString method but

Convert hex to ascii characters

戏子无情 提交于 2019-11-26 16:45:55
问题 Is it possible to represent a sequence of hex characters (0-9A-F) with a sequence of 0-9a-zA-Z characters, so the the result sequence is smaller and can be decoded? For example: $hex = '5d41402abc4b2a76b9719d911017c592'; echo $string = encode($hex); // someASCIIletters123 echo decode(string) == $hex; //true 回答1: You can trivially adapt the solution I presented here using the function base_convert_arbitrary . Edit: I had not read carefully enough :) Base 16 to base 62 is still very doable, as

How to find where does Image Block start in GIF images?

穿精又带淫゛_ 提交于 2019-11-26 14:51:58
问题 Information source - http://www.onicos.com/staff/iz/formats/gif.html#header In GIF images the actual image size (width, height) is stored in Image Block. To my best understanding Image Block is the very first block included in header. Before the actual blocks begin, there is a memory allocation called Global Color Table (0..255 x 3 bytes)(from now-on GCT ). If I can know the byte count reserved for GCT I can extract bytes 5-9 from Image Block and have the actual image size. Question: How can

Decoding Raw H264 stream in android?

北城以北 提交于 2019-11-26 11:50:10
问题 I have a project where I have been asked to display a video stream in android, the stream is raw H.264 and I am connecting to a server and will receive a byte stream from the server. Basically I\'m wondering is there a way to send raw bytes to a decoder in android and display it on a surface? I have been successful in decoding H264 wrapped in an mp4 container using the new MediaCodec and MediaExtractor API in android 4.1, unfortunately I have not found a way to decode a raw H264 file or

Decode gzipped web page retrieved via cURL in PHP

烈酒焚心 提交于 2019-11-26 09:38:39
问题 I\'m retrieving a gzipped web page via curl, but when I output the retrieved content to the browser I just get the raw gzipped data. How can I decode the data in PHP? One method I found was to write the content to a tmp file and then ... $f = gzopen($filename,\"r\"); $content = gzread($filename,250000); gzclose($f); .... but man, there\'s got to be a better way. Edit: This isn\'t a file, but a gzipped html page returned by a web server. 回答1: I use curl and: curl_setopt($ch,CURLOPT_ENCODING ,

Decoding URL parameters with JavaScript

心已入冬 提交于 2019-11-26 07:40:31
问题 This should be a simple task, but I can\'t seem to find a solution. I have a basic string that is being passed through as a query string parameter like this one: This+is+a+message+with+spaces . I would like to decode that parameter using JavaScript to This is a message with spaces , but I cannot seem to get it to decode. I\'ve tried decodeURI(\'This+is+a+message+with+spaces\') but the result still contains the + signs. 回答1: Yes it is true that decodeURIComponent function doesn't convert + to

NodeJS: How to decode base64 encoded string back to binary? [duplicate]

耗尽温柔 提交于 2019-11-26 06:57:00
问题 This question already has answers here : How to do Base64 encoding in node.js? (4 answers) Closed 4 years ago . I was implementing password hashing with salt, so I generated salt as binary, hashed the password, base64 encoded the password and salt then stored them into database. Now when I am checking password, I am supposed to decode the salt back into binary data, use it to hash the supplied password, base64 encode the result and check if the result matches the one in database. The problem

How can I send and receive WebSocket messages on the server side?

冷暖自知 提交于 2019-11-25 23:11:12
问题 How can I send and receive messages on the server side using WebSocket, as per the protocol? Why do I get seemingly random bytes at the server when I send data from the browser to the server? It the data encoded somehow? How does the framing work in both the server → client and client → server directions? 回答1: Note: This is some explanation and pseudocode as to how to implement a very trivial server that can handle incoming and outcoming WebSocket messages as per the definitive framing format