Skip to content

Instantly share code, notes, and snippets.

@whitequark
Last active December 20, 2015 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whitequark/59ae9ed4593726df5fcb to your computer and use it in GitHub Desktop.
Save whitequark/59ae9ed4593726df5fcb to your computer and use it in GitHub Desktop.
emacs compatible unicode (c) erikh
$ ruby x.rb <<<"проверка"
"\M-P\M-?\M-Q\M-\C-@\M-P\M->\M-P\M-2\M-P\M-5\M-Q\M-\C-@\M-P\M-:\M-P\M-0"
$ ruby -e 'puts "\M-P\M-?\M-Q\M-\C-@\M-P\M->\M-P\M-2\M-P\M-5\M-Q\M-\C-@\M-P\M-:\M-P\M-0"'
проверка
Hash.new{|_,v|v.chr}.tap{|m|m[34]='\"';m[92]='\\\\';m[127]='\C-?';
puts '"'+ARGF.read.strip.each_byte.map{|b|b&128==0?m[b]:('\M-'+(
b&96==0?'\C-'+m[b&-129|64]:m[b&-129]))}.join+'"'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment