Hi Isaac and Ryan,

I understand that null characters terminates the sequence in C
strings. The API however, was designed to allow you to create
arbitrary JavaScript strings from UTF8 including null characters. I'm
not sure I understand what the issue is. I haven't been in a situation
where v8::String::New(chr) has been a problem (which does a strlen
internally).

  /**
   * Allocates a new string from either utf-8 encoded or ascii data.
   * The second parameter 'length' gives the buffer length.
   * If the data is utf-8 encoded, the caller must
   * be careful to supply the length parameter.
   * If it is not given, the function calls
   * 'strlen' to determine the buffer length, it might be
   * wrong if 'data' contains a null character.
   */
  V8EXPORT static Local<String> New(const char* data, int length = -1);

Is this a performance issue for you? Does strlen show up high on
profiles? If you have that much string data, do you even want to copy
it to the V8 heap? Would our external strings work for you?

If external strings do not work for you and strlen is actually a
performance problem the right thing to do would be to attempt to avoid
the API strlen call when you do not pass a length and modify the rest
of the system to deal with that. Not sure how much work is involved in
that. However, that would be a change that does not break the
backwards compatibility of the API.

Thanks,   -- Mads

On Wed, Feb 16, 2011 at 8:40 PM,  <[email protected]> wrote:
> Mads,
>
> The issue is that String::New(char*, size_t) is meant to read a UTF8 encoded
> byte array. In UTF8 the null character terminates the sequence.
>
> To achieve the javascript string "\u0000" from a UTF8 sequence the user
> should
> do String::New("\xC0\x80", 2); or String::New("\xC0\x80\0", 3);
>
>
>
> http://codereview.chromium.org/6524031/
>

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

Reply via email to