I'm trying to escape the following code with the echo command but I keep getting the actual octet and not the emoji.
Also where could I find the octet values of the emojis? I seem to always find the UTF-8 values.
#!/usr/bin/env bash
UNICORN='\360\237\246\204\n'
FIRE=''
# this does not work when I run the script
printf '\360\237\246\204\n'
printf "Riding a ${UNICORN:Q}"
echo "Riding a ${UNICORN:Q}" #[Fails]: how to extract the actual emoji?
EDIT_1: Just updating the code after reading comments
#!/usr/bin/env bash
# Note: use hexdump -b to get one-bye octal display
UNICORN_UTF8=$'\360\237\246\204'
printf "U1F525\n"|hexdump -b # [ASK]: How to translate the return value to a valid UTF8 ?
FIRE_UTF8=$'\125\061\106\065\062\065\012'
echo "Riding a ${UNICORN_locale_encoding}"
echo "${UNICORN_UTF8} + ${FIRE_UTF8}"
EDIT_2: Posting final code. It sort of works.
#!/usr/bin/env bash
# Author:
# Usage:
# Note: use hexdump -b to get one-bye octal display of the emoji (needed for when ≠ computers use ≠ commandLine tools)
# Ex: printf "U1F525\n"|hexdump -v -e '"\\" 1/1 "%03o"' ; echo
UNICORN_UTF8=$'\360\237\246\204'
FIRE_UTF8=$'\xF0\x9F\x94\xA5'
LEAVE_SPACE=\^[a-zA-Z0-9_]*$\
echo "Riding an ${UNICORN_UTF8} ${LEAVE_SPACE} out of a ${FIRE_UTF8} ${LEAVE_SPACE} house."
printf? Also see this relevant question unix.stackexchange.com/questions/65803/…\octetand even\nareprintfsyntax. what makes you expectechoknos ho to interpret them?printfandechobehaved the same. New to thisbashand scripting. @MrShunz, main reason is because I would like to use it on an script, and my current scripts hasecho "Ready to git-some and sync your local branches to the remote counterparts ?"