Decode \x{ABCD}-style Unicode escape sequences

perl -e "binmode(STDOUT, ':utf8'); print \"$@\""; echo # newline
This is especially useful to get crazy stuff like space characters copied to your pasteboard correctly. Source: https://github.com/mathiasbynens/dotfiles/blob/master/.functions
Sample Output
$ unidecode "\x{1D306}"
𝌆
$ unidecode "\x{00A9}\x{2122}\x{00AE}"
???

These Might Interest You

  • Get 'ack' now at http://betterthangrep.com/


    -1
    ack --java '\\u.?.?.?[^0-9a-fA-F]'
    hfs · 2012-06-06 08:31:56 0
  • Remove ( color / special / escape / ANSI ) codes, from text, with sed Credit to the original folks who I've copied this command from. The diff here is: Theirs: [m|K] Theirs is supposed to remove \E[NUMBERS;NUMBERS[m OR K] This statement is incorrect in 2 ways. 1. The letters m and K are two of more than 20+ possible letters that can end these sequences. 2. Inside []'s , OR is already assumed, so they are also looking for sequences ending with | which is not correct. This : [a-zA-Z] This resolves the "OR" issue noted above, and takes care of all sequences, as they all end with a lower or upper cased letter. This ensures 100% of any escape code 'mess' is removed. Show Sample Output


    7
    sed "s,\x1B\[[0-9;]*[a-zA-Z],,g"
    Zhoul · 2013-03-18 14:49:30 1
  • This is useful for example if you are on ssh in a server and the server goes down without letting you out. This is part of a larget sets of escape sequences provided by ssh. You can find them with ~? Here's the list: ~. - terminate connection (and any multiplexed sessions) ~B - send a BREAK to the remote system ~C - open a command line ~R - request rekey ~V/v - decrease/increase verbosity (LogLevel) ~^Z - suspend ssh ~# - list forwarded connections ~& - background ssh (when waiting for connections to terminate) ~? - this message ~~ - send the escape character by typing it twice (Note that escapes are only recognized immediately after newline.) Show Sample Output


    11
    <Return>~.
    carlesso · 2013-06-26 13:34:58 0
  • Uses Unicode combining characters to produce strikethrough effect. Since commandlinefu doesn't display Unicode properly, you will need to replace the dash in the code above with the Unicode long stroke overlay (U+0336).


    -1
    echo text | sed "s/\(.\)/\1-/g"
    ppaschka · 2012-03-23 17:18:54 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: