farry

ascii2fraktur

Feb 13th, 2012
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.54 KB | None | 0 0
  1. #! /bin/bash
  2. ## Ascii to Fraktur unicode -- Usage: ascii2fraktur <foo.txt >bar.txt
  3.  
  4. while IFS= read -d$'\0' -r -n1 c                        # read single bytes
  5. do
  6.   printf -vd "%d" "'$c"                                 # decimal ordinal
  7.   (( d >= 65 && d <=90 )) && (( d += 120107 ))          # A-Z -> Fractur bold
  8.   ((d >= 97 && d <= 122 )) && (( d += 120101 ))         # a-z -> Fractur bold
  9.   (( d > 255 )) && printf \\U$(printf "%08X" "$d")      # Unicode UTF-8
  10.   (( d < 256 )) && printf "%s" "$c"                     # Echo other stuff
  11. done
Advertisement
Add Comment
Please, Sign In to add comment