farry

ascii2script

Jun 29th, 2012
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.48 KB | None | 0 0
  1. #!/bin/bash
  2. # Ascii to high unicode script -- Usage: ascii2script "text"
  3. s=$(printf "%s" "$*")
  4. for ((j=0; j<${#s}; j++)); do
  5.   printf -vd "%d" "'${s:j:1}"                           # decimal ordinal
  6.   (( d >= 65 && d <=90 )) && (( d += -65 +0x1D4D0 ))    # A-Z
  7.   ((d >= 97 && d <= 122 )) && (( d += -97 +0x1D4EA ))   # a-z
  8.   (( d > 255 )) && printf "&#x$(printf '%X' $d);"       # HTML entity
  9.   (( d < 256 )) && printf "%s" "${s:j:1}"               # Echo other stuff
  10. done
  11. echo
Advertisement
Add Comment
Please, Sign In to add comment