writeString

[ Function ]

public writeString(value: string, length?: number): this;

Encodes a string as UTF-8 encoded Unicode code points. The optional parameter length determines how many bytes are to be used. If the passed string does not fit into length, an error is triggered. If the passed string is shorter, the remaining bytes are filled with 0. If length is not specified, the number of bytes appended to the data depends on the length of the string.

Parameter

Name

Type

Description

value

string

The string to be written

length [ optional ]

number

The number of bytes to be written. If the string is too short, the remaining bytes are filled with 0. If the string is too long, an error is triggered.

Return value

Type

Description

Base64BinaryWriter

This method returns its parent object to allow concatenation of method calls.

Sample - JavaScript

var writer = new TcHmi.Base64BinaryWriter();
writer.writeString('Hello, World!', 20);
writer.writeString('中文 español हिन्दी العربية русский 日本語');
var result1 = writer.getEncodedString(); // ' SGVsbG8sIFdvcmxkIQAAAAAAAADkuK3mlocgZXNwYcOxb2wg4KS54KS/4KSo4KWN4KSm4KWAINin2YTYudix2KjZitipINGA0YPRgdGB0LrQuNC5IOaXpeacrOiqng=='
writeString 1:

Available from version 1.10