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

class TextEncoder | globals module | Bun

class TextEncoder | globals module | BunBuildDocsReferenceGuidesBlogDiscord/Globals/TextEncoderMencodeMencodeIntoPencoding

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/Globals/TextEncoderMencodeMencodeIntoPencoding

class

TextEncoderclass TextEncoder

TextEncoder takes a stream of code points as input and emits a stream of bytes. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays.

MDN Reference

readonly encoding: stringencode(input?: string): Uint8Array;encodeInto(source: string,destination: Uint8Array): TextEncoderEncodeIntoResult;

Runs the UTF-8 encoder on source, stores the result of that operation into destination, and returns the progress made as an object wherein read is the number of converted code units of source and written is the number of bytes modified in destination.

MDN Reference

encodeInto(src?: string,dest?: BufferSource): TextEncoderEncodeIntoResult;

UTF-8 encodes the src string to the dest Uint8Array and returns an object containing the read Unicode code units and written UTF-8 bytes.

const encoder = new TextEncoder();
const src = 'this is some data';
const dest = new Uint8Array(10);
const { read, written } = encoder.encodeInto(src, dest);
@param src

The text to encode.

@param dest

The array to hold the encode result.

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

class TextEncoder | globals module | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    TextEncoder takes a stream of code points as input and emits a stream of bytes. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays. [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)