2009/3/9 Stephan Beal <[email protected]>:
>
> On Mar 9, 1:28 pm, ry <[email protected]> wrote:
>> Hi
>> I've seen the "Binary data in embedded V8" thread but it is from
>> several months ago.
>> Is any work being done now to make importation/exportation of binary
>> strings possible?
>
> If i'm not mistaken you can stuff binary data into a String by using
> the two-arg ctor:
>
> String::New("....",length_of_data);

If you make an ASCII string then the top bits must be zero so it's not clean.

If you make it a UC16 string then it has to have an even byte length.

So the status is that there isn't any good way to store binary data in
JS at the moment.  Of course it is possible to put the data in an
external object instead.

>
> e.g. over the weekend i wrote an an I/O library (http://
> code.google.com/p/v8-juice/wiki/PluginWhio) and i use vector<char> as
> my read buffer. Once i've populated it i stuff it into a String with:
>
> String::New( &vec[0], static_cast<int>( vec.size() ) ); // i still
> can't believe the second arg is a signed type!!!
>
> that seemed to do the job, and i was reading data with embedded nulls,
> and all of them seemed to make it into JS space.
>
> >
>



-- 
Erik Corry, Software Engineer
Google Denmark ApS.  CVR nr. 28 86 69 84
c/o Philip & Partners, 7 Vognmagergade, P.O. Box 2227, DK-1018
Copenhagen K, Denmark.

--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to