Created
June 7, 2018 20:18
-
-
Save skakri/56fbdd508ec77356a893b156871a698f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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