1

The scenario of my problem: Some data in a file that should be compressed to smaller size. The content of this file is required by the HTML on the fly by using the javascript.

So basically i need to encode that data using C and decode that data using javascript and provide it to HTML.

I am just curious to know if this thing is possible or not, because while decoding we need the binary heap.

6
  • To begin with, there are data structures libraries for javascript, check this. Commented Feb 11, 2013 at 14:07
  • Your file will be a binary file, let say Huffman codewords. one after another. Then yes, you can read write a binary file in c, and read a binary file in Javascript. Commented Feb 11, 2013 at 14:09
  • 2
    Wouldn't it be better to get your server to serve the object stream over a GZIP-compressed connection? But yes, there's no reason you can't implement any decompression scheme in JavaScript. You can certainly represent a tree structure in JavaScript if that's what you're worried about. Commented Feb 11, 2013 at 14:12
  • @Rup The main cause of worry is that the compression has to be done in C and the decompression of has to be done in javascript.Also this has to be done client side, so no server in the picture. Commented Feb 11, 2013 at 14:17
  • 1
    OK, I might be wrong: this question says JavaScript can't handle binary data easily, and there's probably little point compressing data if you then need to e.g. base64 it for transmission or storage. But if there's no server, where's the data coming from?? You're using a C program to generate an HTML file with the compressed data embedded in it? Commented Feb 11, 2013 at 14:30

1 Answer 1

3

Yes, it's possible. Javascript has bit operations that take the value as a 32-bit integer, even though it's stored in a float. That will permit you to do the same things that you do in C to compress and decompress data. It won't be as fast, but it will work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.