2009/12/8 Søren Gjesse <
sgj...@chromium.org>:
> The construct you are using creates a copy of the V8::String into a char*
> bupper allocated for the String::AsciiValue object. This is the only way to
> get a V8::String sitting in the V8 heap as a C string. This is both due to
> GC issues and due to the internal representation of strings in V8 where a
> string object is not necessarily a sequential ASCII buffer.
> However it might be possible for you to use external strings, but of cause
> that depends on the use-case. External strings are strings which have their
> actual string buffer outside the V8 heap, and when you have an external
> string it is possible get pointer to that string buffer without copying the
> string data. External strings can be created either when creating a string
> through the API using v8::String::NewExternal, or an external string can
> replace a normal string using v8::String::MakeExternal. If your strings are
> created from outside V8 in the first place consider v8::String::NewExternal,
> and if you are converting the same strings to c strings again and again
> consider v8::String::MakeExternal.
I think there is a problem with encoding. Google Protocol Buffers
encode strings as UTF-8.
ExternalStringResource's must be either UCS2 or ASCII encoded.
Matthias