Commits

Anonymous committed 019aed6

correct LC_CTYPE for offsets

Comments (0)

Files changed (1)

offsets/offsets.bash

 # combine with offsets.awk to get a listing of word [offset,...] pairs
 # 
 
-unset word off
+unset word off lc lw
 while IFS= read -r -d '' -n 1 c; do
+	lc=$(LC_CTYPE=C; printf %d ${#c})
 	if [[ $c == [[:alnum:]] ]]; then
 		word+=$c
+		((lw += lc))
 	elif [[ $word ]]; then
-		printf "%s %zu\n" "$word" "$((off - ${#word}))"
-		unset word
+		printf "%s %zu\n" "$word" $((off - lw))
+		unset word lw
 	fi
-	((off++))
+	((off += lc))
 done