Skip to content

Instantly share code, notes, and snippets.

@skakri
Created June 7, 2018 20:18
Show Gist options
  • Save skakri/56fbdd508ec77356a893b156871a698f to your computer and use it in GitHub Desktop.
Save skakri/56fbdd508ec77356a893b156871a698f to your computer and use it in GitHub Desktop.
#! /bin/bash
# Ascii to Small Latin
# Usage: thisscript <in.txt >out.txt
# or: thisscript <<<"some-text"
while IFS= read -d$'\0' -r -n1 c # read single bytes
do
printf -vd "%d" "'$c" # decimal ordinal
(( d >= 65 && d <=90 )) && (( d += 65248 )) # A-Z -> small latin
((d >= 97 && d <= 122 )) && (( d += 65248 )) # a-z -> small latin
(( d > 255 )) && printf \\U$(printf "%08X" "$d") # Unicode UTF-8
(( d < 256 )) && printf "%s" "$c" # Echo other stuff
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment