'How can I convert all UTF8 Unicode characters in a string to their relevant Codepoints using bash/shell/zsh?

There seem to be loads of questions about converting 'Codepoints' to utf8, but I can't find an answer anywhere to do it the other way around.

I want to run a script which will convert a string such as My📔 to MyU+1F4D4.

I have tried something like this: DECODEDSTRING=$(echo "My📔" | iconv -f utf-8 -t ASCII//TRANSLIT) but I can't seem to figure out what is needed.

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source