Skip to main content

TextEncoder

Class

Contains methods for Text encoding

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Since Lens Scripting v305

Index

Example

js var encoder = new TextEncoder() let originalStr = "\u223e\u0020\u0045\u22c5\u0064\u0061\u0020\u003d\u0020\u0051" let encodedArr = encoder.encode(originalStr) print("encodedArr="+encodedArr) // result is [226,136,190,32,69,226,139,133,100,97]

Extends

Constructors

Constructor

new TextEncoder(): TextEncoder

Returns

TextEncoder

Overrides

ScriptObject.constructor

Properties

encoding

readonly encoding: string

The encoding format set in the TextEncoder.

Since

Lens Scripting Version 305

Methods

encode()

encode(value): Uint8Array

Encodes a string as Uint8Array. utf-8 by default.

Parameters

ParameterType
valuestring

Returns

Uint8Array

Since

Lens Scripting Version 305


encodeInto()

encodeInto(value, result): void

Encodes and saves the value into the result array.

Parameters

ParameterType
valuestring
resultUint8Array

Returns

void

Since

Lens Scripting Version 306


getTypeName()

static getTypeName(): TypeName<TextEncoder>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<TextEncoder>

Since

Lens Scripting Version 305

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame