Treat ‘length’ in UCharBuffer as number of UChars.

Fixes buffer overflows on OS X.