UNPKG

509 BTypeScriptView Raw
1import type { AnyString } from '../types.js';
2/**
3 * @name stringToU8a
4 * @summary Creates a Uint8Array object from a utf-8 string.
5 * @description
6 * String input values return the actual encoded `UInt8Array`. `null` or `undefined` values returns an empty encoded array.
7 * @example
8 * <BR>
9 *
10 * ```javascript
11 * import { stringToU8a } from '@polkadot/util';
12 *
13 * stringToU8a('hello'); // [0x68, 0x65, 0x6c, 0x6c, 0x6f]
14 * ```
15 */
16export declare function stringToU8a(value?: AnyString | null): Uint8Array;