UNPKG

659 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3import { u8aToString } from "../u8a/toString.js";
4import { hexToU8a } from "./toU8a.js";
5/**
6 * @name hexToU8a
7 * @summary Creates a Uint8Array object from a hex string.
8 * @description
9 * Hex input values return the actual bytes value converted to a string. Anything that is not a hex string (including the `0x` prefix) throws an error.
10 * @example
11 * <BR>
12 *
13 * ```javascript
14 * import { hexToString } from '@polkadot/util';
15 *
16 * hexToU8a('0x68656c6c6f'); // hello
17 * ```
18 */
19
20export function hexToString(_value) {
21 return u8aToString(hexToU8a(_value));
22}
\No newline at end of file