UPDATE: Here is a bash way to do a single Unicode value ...(by "bash" I mean: not using any another scripting language) .. thanks to Gilles for a suggeston in this askubuntu Q/A .
According to this link: recode (Obsoletes iconv, dos2unix, unix2dos).. Edit: but as per the comment below, "obsoletes' may just mean "alternative"
echo -n 0x0965 |recode UTF-16BE/x4..UTF-8
Here is a method to process a raw hex dump as input (ie. no escaped-prefixes like; \u0965, and no \x09\x65)..
xxd is a hex-dump utility (packaged with
vim-common) which can revert a raw hex dump to the characters the dump represents... Unicode Codepoints are UTF-16BigEndian, which is exactly what a Hex-dump is..
xxd in revert mode accepts a stream of Hex values with line breaks.which are ignored.
This script creates a UTF-16BE stream, which it then reverts to the original chars.
The last line contains the two needed commands;
for line in \
"Matsuo Basho (1644-1694)" \
" pond" \
" frog jumps in" \
echo "$line" |iconv -f "$(locale charmap)" -t "UTF-16BE" |xxd -ps -u
# (---this is the **revert** code---)
tee >(xxd -p -u -r |iconv -f "UTF-16BE") ;echo
Here is the output (showing the UTF-16BE hex-dump input, first).
xxd segments its own output with a newline at 60 hex-digits... The revert option ignores these newlines.. it ignores any/all newlines (as the aren't hex-digits)..
Matsuo Basho (1644-1694)
frog jumps in