Skip to content

buffer.indexOf is incorrect in utf16le encoding for odd byteOffset #26448

Description

@hkjackey

Version: v11.10.1
Platform: Windows 10 (64-bits)
Subsystem: buffer
File Encoding: UTF8

Please consider the following 2 lines of code:
let buf = Buffer.from('\u6881\u6882\u6881', 'utf16le');
console.log(buf.indexOf('\u6881', 1, 'utf16le'));

In this example, the expected correct output should be 4.
However, the result is 0.

Metadata

Metadata

Assignees

Labels

bufferIssues and PRs related to the buffer subsystem.confirmed-bugIssues with confirmed bugs.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions