Package: effect
Module: Encoding
Decodes a hexadecimal string into a UTF-8 string safely.
When to use
Use to decode hexadecimal text into UTF-8 text without throwing on invalid input.
Details
Returns Result.succeed with the decoded text when decoding succeeds, or
Result.fail with an EncodingError when the input is not valid hex.
Example (Decoding hex strings)
import { Encoding, Result } from "effect"
const result = Encoding.decodeHexString("68656c6c6f")
if (Result.isSuccess(result)) {
console.log(result.success) // "hello"
}
Signature
declare const decodeHexString: (str: string) => Result.Result<string, EncodingError>
Since v2.0.0