By standard, all asset_name
strings should be encoded as hex
. However, they could also be just hex
, not a UTF-8 string.
Many developers have to use something like this:
CREATE OR REPLACE FUNCTION "convert_asset_name"("name" bytea) RETURNS "varchar"
AS
$$
BEGIN
return convert_from("name", 'utf-8');
EXCEPTION
WHEN character_not_in_repertoire
THEN
return encode("name", 'hex');
END;
$$ LANGUAGE "plpgsql";
It works, but it could work better! So, it was reimplemented in Rust to be more robust.
Release Notes:
The tools_read_asset_name
function has been added. It helps handle asset_name values that may be either UTF-8 strings or raw hexadecimal values. If the input is valid UTF-8, it is returned as a string. Otherwise, the function encodes it in hex format.