Subj : spidermonkey: byte arrays - again To : netscape.public.mozilla.jseng From : Jens Thiele Date : Thu Sep 16 2004 12:22 pm Hi, I am at the byte arrays again ;-) Intro: Unfortunately Javascript does not have a native/primtive c-style byte array for raw data. Especially when wrapping native code you need it. (For example networking, image processing, compression/decompression, ....) Possible "solutions": 1. use javascript string: a) only use 8bit of 16bit chars + simple - bloat - confusing / error prone b) use all 16 bit - what about odd number of bytes? needs some ugly hack 2. use javascript array: I only did a quick look at how the arrays are done and guess this would be real bloat 3. write some native/host object: + efficient (memory and cpu) - no literal notation => solution 1 or 2 needed to get something close to a literal notation: new ByteArray("thisisraw8bitdatastoredin16bit") new ByteArray([10,20,30,...]) new ByteArray("\u3744\u....",odd|even) or similar hack probably best thread for implementing 3: http://groups.google.de/groups?th=35ba422a08cd0319 Now the real question: Did someone write a ByteArray object/class and wants to share the code? Thanks Jens .