Differences between version 2 and previous revision of CyberLeo/Scraps/GoogleCharts.
Other diffs: Previous Major Revision, Previous Author
| Newer page: | version 2 | Last edited on Sunday, 4 July 2010 20:25:41 | by CyberLeo | Revert |
| Older page: | version 1 | Last edited on Sunday, 4 July 2010 20:25:28 | by CyberLeo | Revert |
@@ -1,5 +1,5 @@
-Convert integers to Extended Value format (bourne shel
):
+Convert integers to Extended Value format (bourne shell
):
<code brush="bash">
ev_map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-."
int_to_ev() {
int="${1}"
version 2
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})"
}
