Its more serious than a just little "quirk". Many binary protocols use
Pascal type strings where the length is stored explicitly, then
String::WriteUtf8 can't be used. V8 should atleast skip writing \0
when HINT_MANY_WRITES_EXPECTED is specified, that would be logical.

On Jul 4, 7:25 pm, Chris Angelico <[email protected]> wrote:
> On Tue, Jul 5, 2011 at 3:19 AM, Henrik Lindqvist
>
> <[email protected]> wrote:
> > I've noticed this too. It always write and counts the null-terminator,
> > even when specifying HINT_MANY_WRITES_EXPECTED. This makes WriteUtf8
> > somewhat useless when used to encode a string into a binary buffer
> > where you don't want null-termination, i.e. sockets transfer.
>
> Well, it's wasting some effort. You just have to decrement the count
> that you get back. It's not impossible to deal with, but it just has
> that anomalous feeling of 'struct tm' from the C standard library -
> day of month is 1-31, but month of year is 0-11. The true anomaly is
> the day of month, which ought to be 0-30 to parallel the
> hour/minute/second, but civil time is usually displayed starting from
> 1 in the day and month, and it feels weird to have it come out
> differently. WriteUtf8 can logically be explained as returning the
> count of bytes written, but 'most every other function that does this
> sort of job won't count the null.
>
> Chris Angelico

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

Reply via email to