温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/string_decoder
点击访问原文链接

Node.js string_decoder module | API Reference | Bun

Node.js string_decoder module | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:string_decoderCStringDecoder

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:string_decoderCStringDecoder

Node.js module

string_decoderThe 'node:string_decoder' module provides the StringDecoder class, which decodes Buffer data into strings while preserving multi-byte UTF-8 and other encodings across buffer boundaries.

It ensures that decoded strings are not truncated or malformed when chunked data arrives in separate buffers.

Works in Bun

Fully implemented. 100% of Node.js's test suite passes.

class StringDecoderend(buffer?: string | ArrayBufferViewArrayBufferLike>): string;Returns any remaining input stored in the internal buffer as a string. Bytes representing incomplete UTF-8 and UTF-16 characters will be replaced with substitution characters appropriate for the character encoding.

If the buffer argument is provided, one final call to stringDecoder.write() is performed before returning the remaining input. After end() is called, the stringDecoder object can be reused for new input.

@param bufferThe bytes to decode.

write(buffer: string | ArrayBufferViewArrayBufferLike>): string;Returns a decoded string, ensuring that any incomplete multibyte characters at the end of the Buffer, or TypedArray, or DataView are omitted from the returned string and stored in an internal buffer for the next call to stringDecoder.write() or stringDecoder.end().

@param bufferThe bytes to decode.

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco

We're hiring →

智能索引记录