Note: You are viewing an old version of this page. View the current version.

Convert integers to Extended Value format (bourne shell):

ev_map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-."
int_to_ev() {
  int="${1}"
  if [ ! "${int}" ]
  then
    printf "__"
    return
  fi
  [ "${int}" -lt 0 ] && int=0
  [ "${int}" -gt 4095 ] && int=4095
  hob=$(( ( ${int} / 64 ) + 1 ))
  lob=$(( ( ${int} % 64 ) + 1 ))
  printf "%s%s" "$(echo "${ev_map}" | cut -c${hob})" "$(echo "${ev_map}" | cut -c${lob})"
}