#!/usr/bin/env bash # uni2asc - Convert specific Unicode characters to ASCII equivalents # Usage: uni2asc input.txt [output.txt] # Set your preferred editor (change xed to vim, nano, etc.) EDITOR="xed" if [[ "$1" == "-h" || "$1" == "--help" || $# -eq 0 ]]; then echo "" echo " .-------------------------------------------------------------------." echo " | uni2asc - Converts common Unicode characters into their ASCII |" echo " | equivalents using sed. |" echo " | |" echo " | USAGE: |" echo " | uni2asc (Prints to screen) |" echo " | uni2asc (Saves to file) |" echo " | uni2asc --edit (Edit this script) |" echo " | uni2asc --help (Displays this help) |" echo " | |" echo " | ----------------------------------------------------------------- |" echo " | Blue Oak Model License 1.0.0 | (c) 2026 - 640kb.neocities.org |" echo " '-------------------------------------------------------------------'" echo "" exit 0 fi if [[ "$1" == "--edit" ]]; then "$EDITOR" "$0" exit 0 fi input="$1" output="$2" if [[ ! -f "$input" ]]; then echo "" echo " Error: Input file '$input' not found" >&2 echo "" exit 1 fi export LC_ALL=${LC_ALL:-en_US.UTF-8} # --- Streaming Unicode -> ASCII conversion --- sed_script=' s/“/"/g s/”/"/g s/‘/'\''/g s/’/'\''/g s/—/-/g s/–/-/g s/…/.../g s/•/*/g s/´/'\''/g s/©/(C)/g s/®/(R)/g s/™/(TM)/g s/°/deg/g s/→/->/g s/é/e/g s/ñ/n/g s/ç/c/g s/┌/./g s/┐/./g s/└/'\''/g s/┘/'\''/g s/│/|/g s/─/-/g s/├/+/g s/┤/+/g s/┼/+/g s/✓/[OK]/g s/✔/[OK]/g s/✗/[X]/g s/✘/[X]/g s/×/x/g s/÷/\//g ' if [[ -n "$output" ]]; then sed "$sed_script" "$input" > "$output" echo "" echo " Converted: $input -> $output" >&2 echo "" else sed "$sed_script" "$input" fi