Creating byte collection in old browsers via JavaScript?

2

I was wondering if there is something like Uint8Array in old browsers (to a minimum in IE8), a collection type with elements that occupy only 1 byte of browser memory.

An approximation would be to use strings , but as far as I know, browsers use UTF-16 encoding that uses 2 (or more, I guess) bytes for each character.

On the Moon, for example, something that would help to create something like Uint8Array would be a string (because there, each character of a string is 8 bits) . But a string has to be recreated to be modified, so I do not think it's a good idea.

Q.: The Cheat Engine (or some similar tool) can help you see the browser's memory. Below is a list of fixed bytes created by an instance of U\u{69}nt8Array .

So, is there any way to do this to a minimum in IE8 via JavaScript (or in combination with VBScript)? The bytes in this collection will have to be modified occasionally.

    
asked by anonymous 31.12.2016 / 17:55

1 answer

3

JavaScript is probably not the most appropriate language for this. It was not created thinking of minimizing memory usage and making your access more flexible. Now you are including that sort of thing a bit.

What you can do, but it is a tremendous trick, it is to use string and put two data into each character since JS is specified to use UTF-16. You'll have to create a library to make this composition and access it any way you want. The maximum you will have to waste is one byte if you have an odd number of elements.

It can be done with the numeric type too, although it is a slightly more difficult composition to make. I would have to look at all the implications, I do not know if it's such a good idea to put in an array depending on the engine of the used JS.

Given the difficulties, I'd say it's best to forego this or the requirement to work on legacy browsers.

    
31.12.2016 / 18:10