Skip to content

utf16leSlice behaviour differs from node.js #251

@roaringUnicorn

Description

@roaringUnicorn

Problem

const oddLengthBuffer = Buffer.from('abcde', 'utf8')
console.log(Buffer.from(oddLengthBuffer.toString('utf16le'), 'utf16le').toString('utf8')) // ‘abcd’ in Node.js and ‘abcd\x00\x00’ with polyfill

This comes from accessing n+1-th element of a Buffer of size n in utf16leSlice.
Node.js simply omits it.

Proposed solution: #250

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions