Subj : Re: spidermonkey: byte arrays - again To : netscape.public.mozilla.jseng From : Jens Thiele Date : Mon Sep 20 2004 11:37 am Shanti Rao wrote: > Jens, > > What are you using it for? Arbitrary indexing and manipulation, or > sequential scanning of text? > I contacted Sajid Raza (the poster in the thread I mentioned) by private mail and he has written a ByteArray class which closely meets my requirements / what I would have written. I now am awaiting his reply if he wants to release this under some open source lincense so I could post a link. My thoughts about what a ByteArray should have: Native operations needed: (all operations must be safe - range checked, additional operations could also be added in Javascript itself) get size set size/resize (fill new bytes with zero or optionally given value) get byte set byte move bytes within byte array (like memmove) copy bytes from other byte array (like memcpy) ByteArray <-> js string: convert to / interpret as iso-8859-1 string (as 8-bit subset of ucs-2) convert to / interpret as js string (ucs-2) - odd number of bytes? set from ucs-2 js string set from ucs-2 js string (interpreted as 8-bit iso-8859-1 string) ByteArray <-> js array? toSource()? Jens .