UNPKG

562 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3import { u8aToHex } from "../u8a/toHex.js";
4import { stringToU8a } from "./toU8a.js";
5/**
6 * @name stringToHex
7 * @summary Creates a hex string from a utf-8 string
8 * @description
9 * String input values return the actual encoded hex value.
10 * @example
11 * <BR>
12 *
13 * ```javascript
14 * import { stringToHex } from '@polkadot/util';
15 *
16 * stringToU8a('hello'); // 0x68656c6c6f
17 * ```
18 */
19
20export function stringToHex(value) {
21 return u8aToHex(stringToU8a(value));
22}
\No newline at end of file