One observation.
I can't copy your character string. I tried a couple of
ways, and like in some of your quoted material with the
??????, the six characters also seem to render as
six square boxes, as if six 0x00 bytes are ending up
in the clipboard.
You probably need a different way to encode the characters.
https://unix.stackexchange.com/questions/250366/how-to-force-shell-script-characters-encoding-from-within-the-script
#!/bin/bash --utf8 <=== well, that's not even a valid option today
locale, LC_CTYPE, LC_ALL <=== this could help, might improve terminal response, maybe...
We need to keep our table handy. Code point is on the end. That hex wasn't useful.
BottleWithPoppingCork: UTF-8 Encoding: 0xF0 0x9F 0x8D 0xBE U+1F37E
WrappeGift: UTF-8 Encoding: 0xF0 0x9F 0x8E 0x81 U+1F381
BirthdayCake: UTF-8 Encoding: 0xF0 0x9F 0x8E 0x82 U+1F382
PartyPopper: UTF-8 Encoding: 0xF0 0x9F 0x8E 0x89 U+1F389
ConfettiBall: UTF-8 Encoding: 0xF0 0x9F 0x8E 0x8A U+1F38A
Balloon: UTF-8 Encoding: 0xF0 0x9F 0x8E 0x88 U+1F388
Now, this is where it gets interesting.
https://stackoverflow.com/questions/27652458/whats-the-best-way-to-embed-a-unicode-character-in-a-posix-shell-script
export LANG=C.UTF-8 # Persistent, in the shell you execute it in.
# Might take the place of bash --utf8 idea.
# You could test the first example, both without and then with this.
# There example, prints in terminal. Scary. Some output.
printf $(printf '\\%o' $(printf %08x 0x2388 0x266c 0xA | sed 's/../0x& /g')) | iconv -f UTF-32BE -t UTF-8
# Go to LibreOffice Writer and paste and get two characters as expected. So pipe to "xclip" eats this OK.
printf $(printf '\\%o' $(printf %08x 0x2388 0x266c 0xA | sed 's/../0x& /g')) | iconv -f UTF-32BE -t UTF-8 | xclip -selection clipboard
# Substitute the code points and retest. This prints six emoji in terminal. Put all
# of this in a single terminal command.
printf $(printf '\\%o' $(printf %08x 0x1F37E 0x1F381 0x1F382 0x1F389 0x1F38A 0x1F388 0xA |
sed 's/../0x& /g')) | iconv -f UTF-32BE -t UTF-8
# But xclip is barfing if I do this.
printf $(printf '\\%o' $(printf %08x 0x1F37E 0x1F381 0x1F382 0x1F389 0x1F38A 0x1F388 0xA |
sed 's/../0x& /g')) | iconv -f UTF-32BE -t UTF-8 | xclip -selection clipboard
Does it need a different clipboard tool ?
Or is the idea broken ?
You decide :-)
Paul