Kit
Functions

padNullCharacters

padNullCharacters(value, chars): string

Pads a string with null characters (\u0000) at the end to reach a fixed length.

If the input string is shorter than the specified length, it is padded with null characters until it reaches the desired size. If it is already long enough, it remains unchanged.

Parameters

ParameterTypeDescription
valuestringThe string to pad.
charsnumberThe total length of the resulting string, including padding.

Returns

string

The input string padded with null characters up to the specified length.

Example

Padding a string with null characters.

padNullCharacters('hello', 8); // "hello\u0000\u0000\u0000"

On this page